javascript - Retain dropdown selection when clicking on back -


i have 2 jsp files,in jsp1 have dropdown menu.from i'm passing value second jsp. have back button in second jsp , when click of coming first jsp have remember selection of dropdown list.i cant achieve second case.

first jsp

<select id="parenttype" > <option value="">select</option> <% for(string s:typelist) { %> <option value="<%=s%><%=(s.equals(request.getparameter("value"))?"selected" : "")%> ><%=s%></option> <%} %> 

i'm passing value second jsp , have tried compare option values above.it not showing values inside dropdown have empty selection.

from second jsp

function gt3() { var val="<%=selectedtype%>"; window.location.assign("gt_iba?value="+val); } 

what need when click of button jsp2 selected value should remain same in jsp1. better without use of storing values in session because can used in client side only,but if i'm wrong correct me in also.any before mark question duplicate.

you missing quote in

<option value="<%=s%><%=(s.equals(request.getparameter("value"))?"selected" : "")%> ><%=s%></option> 

should

<option value="<%=s%>" <%=(s.equals(request.getparameter("value"))?"selected" : "")%> ><%=s%></option> 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -