Re: Reset in form

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

« previous php.windows (#2510) next »