Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 9 | Q359 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.