Click to See Complete Forum and Search --> : form reset not working when running in CGI


lindamoran
02-07-2005, 03:59 PM
Hi. I could use someone's help. I have a form running in a Perl script. I expected that the reset button would work normally even when the form is running dynamically in a Perl script, but it doesn't clear some of the fields, and it even restores fields that the visitor has blanked out.

Are there any known problems/workarounds/glitches or programmer errors specific to using a reset button in a form that's running in a script? Thanks.

Here's the form: The form in its orignal html page (http://www.betterwaypress.com/publishing/BWordernewsletter.html )
First, make the form fail (such as leave out your e-mail address) so that when it redisplays with an error message, you're now running it in a Perl script. Next try resetting the form when you have fields already filled out. You'll see that it behaves oddly.

Linda Moran

My writer site (http://www.lindamoran.net)
Betterway Press (http://www.betterwaypress.com)

Nedals
02-07-2005, 09:48 PM
The reset button will restore the form to what was initially downloaded. If your Perl script sends a partially completed form, that is then edited, the reset button will set it back to what you sent.

If you want to clear the form you will need to add a little javascript.

lindamoran
02-08-2005, 03:22 AM
Oh, I see. Thanks! Anybody out there know where I could find the Javascript for this? I don't know javascript.

Linda Moran

lindamoran
02-09-2005, 03:01 AM
Someone gave me an answer. This solution uses an onclick handler for a button, rather than a handler to change reset. It works!

<input type="button" value="Clear form" name="Reset" onclick="doReset()">


<script language="Javascript">
function doReset()
{
document.forms[0].visitoremail.value = '';
document.forms[0].visitoremailtwo.value = '';
document.forms[0].firstandlastname.value = '';
}
</script>

Nedals--thanks again for explaining this.

Linda Moran
My new form (http://www.betterwaypress.com/publishing/BWordernewsletter.html)