Reset in form
| From: | James Duncan | Date: | Thu, 07 Sep 2000 16:27:53 +0000 |
| Subject: | Reset in form | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-2505@lists.php.net to get a copy of this message | ||
I have a form that posts to itself. Data validation occurs when the user
clicks the Submit button. If validation succeeds then an email is generated
and sent, otherwise the form is redisplayed. I repopulate the form fields so
the user doesn't need to re-enter the same data, like so:
<input type="text" name="FromAddr" size="25"
<?php
print "value=\"$FromAddr\"><font color=\"#FF0000\">
$FromAddrErr";
?>
</font></font></p>
Everything works fine, except for Reset. If the user enters data into the
fields and clicks on Reset before clicking on Submit, then all fields are
cleared. However, once Submit has been pressed the Reset button doesn't
clear the data in fields that was entered before the last submit. This is
because the variable(s) now contain the data, and the Reset button can't
clear the variable. However, I'm having trouble detecting in PHP that the
Reset button has been pressed. I need to detect this so that I can reset all
the variables to empty.
Is this possible and if so how? How does the "Reset" operation work? Does
the browser simply return all the fields to the values that were set when
the form loaded? If this is the case then I won't be able to use the "Reset"
button. I can't use Javascript either. For example, I can use Javascript to
change the value of the text field (to "") but then it's immediately changed
back by the form refresh. I can prevent the form refresh by using return
false; However, if the user refreshes the page then the original value is
restored because I still haven't actually reset the variable value.
Thanks
James