faqts : Computers : Programming : Languages : JavaScript : Document

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 3 people (100%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

How can I achieve the same as using a "reset" button, in JavaScript?

Jul 31st, 2001 00:24
Joe Lipman, Kevin Smith,


I would have assumed that it was the reset() method
eg.
<FORM NAME="loadsaFields">
     <INPUT NAME="fieldtoReset" VALUE="Hello">
</FORM>
and where header contains function to call upon
<SCRIPT LANGUAGE="JavaScript">
<!--
    function resetMe() {
         document.loadsaFields.reset();
    }
//-->
</SCRIPT>
If you already have a reset button in your form, you can emulate the 
click on the reset button
<FORM NAME="loadsaFields">
     <INPUT NAME="fieldtoReset" VALUE="Hello">
     <INPUT TYPE="reset" NAME="goingToReset" VALUE="Reset">
</FORM>
the header would contain
<SCRIPT LANGUAGE="JavaScript">
<!--
    document.loadsaFields.goingToReset.click();
//-->
</SCRIPT>