Reputation: 645
This is my code of JSP :
<%if (session.getAttribute("user").toString().equalsIgnoreCase("Chhattisgarh")){ %>
<select name="district" id="district" onchange="this.form.submit()">
<c:forEach var="row" items="${result.rows}">
<option value="${row.UserDispName_Eng}">${row.UserDispName_Eng}</option>
</c:forEach>
</select>
<%} else{
out.println(session.getAttribute("user"));
} %>
i need to load another dropdown depending upon the selection made in this dropdown. i saw a post similar to it, but it didn't worked for me. How to keep Dropdownlist value same after refresh the page
what should i do to achieve this.
Upvotes: 0
Views: 2122
Reputation: 1
Save the option value selected in session and compare after for example:
if(session.getAttribute("user_dispname").equals("${row.UserDispName_Eng}")){
selected = "selected=\"selected\"";
}else{
selected = "";
}
<option ${selected} value="${row.UserDispName_Eng}">${row.UserDispName_Eng}</option>
Upvotes: 0
Reputation: 258
You can do one thing. on selection of any option call one java script function created by you.Write a code to create a new drop down html into it and set condition in that which set the right option as per your selection of first option.
onchange="callAnotherDropDown();"
Javascript
function callAnotherDropDown(){
html code.
creation of new drop down.
condition to select the proper value.
}
Upvotes: 1