How to catch reset of a form not before, but right after the event?

J

John Smith

Hello. Can anybody read this and come up with the solution? I would
appreciate any input.

In my form I have two fields (Field1 is select and Field2 is text input).
Field1 has "onchange" event which fires a function which hides or displays
Field2 depending on chosen value of Field1 by means of manipulating style
"display" property setting it to "none" or "inline".

Everything works fine, but only problem is reset button. When Field1 is
reset then onchange for Field1 is not triggered. So, I have a situation when
Field2 is displayed or hidden when it should not be according to value
Field1.

I tried to use "onreset" event to put there the logic of hiding/displaying
of Field2, but this event seems to trigger BEFORE and not right AFTER reset.
So, I don't have reset value of Field1 at that moment.

Thanks
JS
 
K

kaeli

Hello. Can anybody read this and come up with the solution? I would
appreciate any input.

In my form I have two fields (Field1 is select and Field2 is text input).
Field1 has "onchange" event which fires a function which hides or displays
Field2 depending on chosen value of Field1 by means of manipulating style
"display" property setting it to "none" or "inline".

Everything works fine, but only problem is reset button. When Field1 is
reset then onchange for Field1 is not triggered. So, I have a situation when
Field2 is displayed or hidden when it should not be according to value
Field1.

Call the same function when the user hits reset.

<input type="reset" onclick="whateverFunctionToClearBoxes();">


-------------------------------------------------
~kaeli~
Black holes were created when God divided by 0.
Not one shred of evidence supports the notion
that life is serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,184
Latest member
ZNOChrista

Latest Threads

Top