Re: PHP button
| From: | Marek Kilimajer | Date: | Mon, 26 Apr 2004 12:28:18 +0000 |
| Subject: | Re: PHP button | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184621@lists.php.net to get a copy of this message | ||
Brent Clark wrote:
Hi all
I have been for some time trying to get this right
I need to diable a button, which I can do with javascript, all works fine
until the submit \ posting part .
this is my part of my code below:
This is my form section:
---------------------------
<form action="scanbatch.php" method="POST" name="frm" >
This is my php code, if the conditions are met:
-----------------------------------------------
echo "<input type=\"button\" name=\"read\" value=\"Next\"
onclick=\"dob();\">";
This is my javascript:
-----------------------
<script language="javascript">
<!--
function dob(){
document.frm.read.disabled=true;
document.frm.submit();
}
//->
</script>
The button does disable the button like it should
the problem is that, apart from the disabling of the button, the does not
update my database.
In fact it does nothing
BUT
if I change the "type" from "button" to "submit" in the <input> tag.
Then it works
You SHOULD change the type of the button to "submit" so even javascript disabled browsers can use your form. Then you need only:
echo "<input type=\"submit\" name=\"read\" value=\"Next\" onclick=\"this.disabled=true;\">"
And remember that browsers don't post disabled inputs. If you have a condition in your action script like
if($_POST['read'] == 'Next') ...
this will be false even if you click the submit button.
I cant find away for this to work. (Co exist) Could someone please help I feel the problem defiantly lies with PHP Kind Regards and thanks in advance Brent Clark