I have a JSP page in which there are two forms.
- One is the default and another is hidden.
- On default form, there is a link to the hidden form. On click of this link, the hidden form appears which has some input fields and submit button.
- When I click on submit, obviously the form gets submitted.
But when the output comes, the page gets loaded and shows the default form. I want to show hidden form instead. What should I do?
My JSP page has following code structure:
<div id="1st_form">
<form id="defaultForm" action="/searchModel/search">
%{-- form input fields--}%
<div style="float: left; margin-left: 15px;">
<a href="javascript:advancedSearch();" style="color: #ffffff; font-size: 13px;">Advanced Search</a>
</div>
</form>
</div>
<div id="2nd_form" hidden="hidden">
<form id="hiddenForm" action="/searchModel/search">
%{-- form input fields--}%
<input type="submit" id="searchButton" value="Advanced Search" >
<div style="float: left; margin-left: 15px;">
<a href="javascript:normalSearch();" style="color: #ffffff; font-size: 13px;">Advanced Search</a>
</div>
</form>
</div>
And javascript functions are as follows:
function advancedSearch(){
$("#1st_form").hide();
$("#2nd_form").show();
}
function normalSearch(){
$("#2nd_form").hide();
$("#1st_form").show();
}