I have a dropdown list. When I select a value, the page is refreshed. Then, the combo box is still showing the default value. What I want is to maintain the selected value inside combo box even after onchange.
Here is the code ....
Here is the code ....
Code:
<select size="1" name="ddlSelect" id="ddlSelect" onchange="fnChange(this.value)" >
<option value="0">--- Select One ---</option> <%
String selectedname="";
ArrayList<Profile> userlist = Controller.UserNameList(Profile.userId,year);
for (Profile j : userlist) {
selectedname = (!cbmUtil.isNull(j.userName)) ? "selectedname" : "";
out.write("<option " + selectedname + " value='" + j.userName + "'>" + j.userName + "</option>");
}
%> </select> <script type="text/javascript">
function fnChange(Index){
var userName = $("#ddlSelect option:selectedname").val();
if(!userName){return false;}
document.location.href="testpage.jsp?fn=pChange&userName="+userName;
}
</script>
Comment