Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q359 Why can't I set the form values to some setting other than their default setting when using a forms onReset event handler?

You are here: irt.org | FAQ | JavaScript | Form | 9 | Q359 [ previous next ]

Because the code invokde by the onReset event handler is performed before the form is reset - hence undoing any changes you make to the form yourself.

Use a timer to set the form field values *after* the form has been reset:

<SCRIPT LANGUAGE="JavaScript"><!--
function setForm() {
    document.myForm.myText.value = 'my value';
}
//--></SCRIPT>

<FORM NAME="myForm" onReset="setTimeout('setForm()',100)">
<INPUT NAME="myText" TYPE="TEXT" VALUE="default">
<INPUT TYPE="RESET">
</FORM>

Feedback on 'Q359 Why can't I set the form values to some setting other than their default setting when using a forms onReset event handler?'

©2018 Martin Webb