I have dynavalidator form and I want to clear the fields on pressing clear. Below are the two options that i tried and it did not work.
The reason being(I think..).. I have a Insert screen and once submit is presssed I take them to a confirmation screen. If user presses cancel in the confirm screen, I bring them back to Insert screen(displays values previously entered). Now if user tries to press clear button ...clear does not clear the screen. why is this happening?
The JavaScript code you present should work if you correct a few errors. Change 'radio' to 'RADIO' (Upper Case). Also, if you're trying to clear inputs created with the <html:text> tag, you should change 'textarea' to 'TEXT'.
the javascript works fine. But I think the clear should be done at server side. My DynaValidatorBean still holds the value even if I just clear the screen using javascript. So I have created a action class but I am not sure how to reset values of my DynaValiatorBean.
I did this in MresetAction class
dynaValidatorMForm.reset(mapping, request); it does not work.
My screen flow is INSERT screen--->ConfirmInsert screen (If cancel presed inside confirm screen)then back to INSERT Screen (if I press clear now it does nothing)
Are you talking about using the html:reset tag (same applies to the standard reset input tag)? If so then the functionality of that button is to reset all the fields back to the value they were when the page was displayed. Here is a thread with some info on the html:reset tag:
The reset method of DynaActionForm sets each field to the value specified in the "initial" attribute if you also specified reset="true" for that field. Otherwise, the reset method does nothing.
Another way to do it is is just to write code in your Action class that sets a default value (i.e. blanks or zeros) in each individual field. [ February 28, 2007: Message edited by: Merrill Higginson ]