|
Subject:
|
JSP combo box
|
|
Posted By:
|
cosmicx
|
Post Date:
|
11/29/2006 7:43:25 AM
|
<select NAME="Tour" onchange="frmDisplay.submit()">
<% String temp2 = "";
while(rsTour.next()){
temp2 = rsTour.getString(1);
if (temp2 == tour) { %>
<option selected><%=temp2 %></option>
<% }else{ %>
<option><%=temp2 %></option>
<% } } %>
<option><%=tour %></option>
</select>
this is my code for a combo box in my html form. However, I want the combo box show me the value i selected before submit. But, it will only show me the default first value. For example, I choose "BBB", but after the event on change, and come back to this page, it will show "AAA" which is the first choice. Is there anyway to show my selection as the default ?
thank you 
|
|
Reply By:
|
SachinMangla
|
Reply Date:
|
12/15/2006 6:27:50 AM
|
For Solving ur problem just place ur if condition in side the option box. and in between of option write selected. then hope when u change valus ur selected value vl not change. like:---
<select NAME="Tour" onchange="frmDisplay.submit()"> <% String temp2 = ""; while(rsTour.next()){ temp2 = rsTour.getString(1); %> <option <%if (temp2 == tour) {%>selected <%}%>><%=temp2 %></option> <option><%=temp2 %></option> <% } %> <option><%=tour %></option> </select>
this is my code for a combo box in my html form. However, I want the combo box show me the value i selected before submit. But, it will only show me the default first value. For example, I choose "BBB", but after the event on change, and come back to this page, it will show "AAA" which is the first choice. Is there anyway to show my selection as the default ?
Sachin Mangla Software Developer Delhi
|
|