By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

Form reset method

P: n/a
I need to reset a form to its original value using onclick rather than the
Reset button. So, I have:

<input type="button" name="reset" id="reset" value="Reset"
onclick="form1.reset();"> where the id of my form is "form1".

This gives the error "Object doesn't support this property or method".

Please advise.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Mar 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Roger Withnell wrote on 30 mrt 2006 in comp.lang.javascript:
<input type="button" name="reset" id="reset" value="Reset"
onclick="form1.reset();"> where the id of my form is "form1".

This gives the error "Object doesn't support this property or method".


This:

===========================
<form name=form1>
<input>
</form>

<input type="button" value="Reset"
onclick="form1.reset();">
=============================

works fine in IE,
in other browsers you would probably have to
change form1.reset() to:

document.forms['form1'].reset()

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 29 '06 #2

P: n/a
Roger Withnell said on 30/03/2006 8:11 AM AEST:
I need to reset a form to its original value using onclick rather than the
Reset button. So, I have:

<input type="button" name="reset" id="reset" value="Reset"
onclick="form1.reset();"> where the id of my form is "form1".

This gives the error "Object doesn't support this property or method".


Because by giving your button either a name or id of 'reset' (you've
done both) you hide the native reset method of the form - form1.reset is
now a reference to the button named 'reset', not the reset method. And
HTML buttons don't have a reset method.

Your button doesn't need an ID or name, so just remove it. If you must
give it a name or id, use something else like 'resetButton' - anything
but 'reset' (or 'Reset').
--
Rob
Mar 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.