Yeah, the reset button will return the form elements to their initial state.  If the 
initial state includes values, i.e. <input type="text" value="someValue">,  then 
clicking reset will set the value of this element to "someValue", it's original value.

One solution is to write a function that loops throught the form elements and set text 
inputs to '' and so on.

Something like <input type="reset" onclick="resetForm(this); return false;">

and then function would be:  (untested)

resetForm(theForm) {
        while (i = 0; i < theForm.elements.length; i++) {
                theElement = theForm.elements[i];
                if (theElement.type == 'text') {
                        theElement.value = '';
                } else if (theElement.type == 'choose-one') {
                        theElement.selectedIndex = 1;
                }

                ...
        }

If you're not sure what the type attribute will be for a form element, then you can 
alert(theElement.type).  I might have some code I can dig up for this if you need more 
help.  

-Dave

        



> -----Original Message-----
> From: Gus Delgado [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 10, 2003 12:48 PM
> To: Struts Users Mailing List
> Subject: Reset button.
> 
> 
> I have created a JSP with a "Submit" and "Reset" button both 
> using the 
> <html:submit> and <html:reset> tags. When I first render the page the 
> reset works just fine, but if I hit the submit button and the 
> page gets 
> render again, I try to hit the reset and the form does not get clear 
> anymore, the reset button does not work anymore, any ideas of 
> why this 
> is happening? any ways to fix it?
> 
> thank you
> 
> -Gus
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to