I have a form in which there is a reset button and three list box(Select Box) and submit button.
In which i have reset button like.
<s:reset name="reset" type="reset" id="reset" ></s:reset>
when i click on this before submit the page. it will reset the list box means it will select the default value of 'Select' Index = -1 means working fine. but after i submit the page. this will come to the same page with latest records. after that when i click the reset button. it will not give any response to that page. it should be change the default value of list box means "select" but it will select the last开发者_JAVA百科 value of the list box (The value i selected before save button clicked). i change it to simple Html reset button also but still not get success. can you please help me abt this solution.
Thanks in Adv Dhrumil Shah
the reset functionality only works in the current page stage (ie., it will reset the page to whatever state the page was in when it was loaded). since http is a stateless protocol it can't remember what was the value of the select box before the page was reloaded or submitted.
you can use javascript (jquery preferably) to accomplish things like this...
$("select").val(-1);// this would reset all combo boxes in the page to value -1
$(":text").val("");// this would reset all textboxes in the page to blank
$("textarea").val("");// this would reset all textarea in the page to blank
you can find more about jquery here.enter link description here
The <s:reset />
will renders as html <input type="reset"...>
, of course it will not reset the submitted form.
@Dhrumil Shah
In which i have reset button like.
<s:reset name="reset" type="reset" id="reset" ></s:reset>
when i click on this before submit the page
The type is type of submit to use, valid values are input
, button
and image
, default is input
You should use <s:a>
to reset the form (reload the page). e.g.
<s:a><button>Reset</button></s:a>
Or
<s:a cssClass="button-like-css">Reset</s:a>
精彩评论