Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box problem

Status
Not open for further replies.

MONFU

Programmer
Oct 27, 2001
35
MT
Good morning All,

I have an asp with 2 forms, one that has a Combo Box, and the other to display the items depending on the Combo box. Issa after choosing an item from the Combo box and pressing submit, I call the same ASP and display the items pertaining to that selection. The problem is that the Combo box does not remain with the name that I have chosen, but resets its value and displays the first item again.

Can you tell me how to make the combo box retain its value and displaying the last item that I have chosen?

Thanks
 
Hi

When you submit the form, is the submit from the form with the first combo box in it? If it is the value of the combo box that you have selected will be passed as a form parameter. Then you can reselect the value in the combo box on the new page using this:

Code:
<% yourvar = request.form(&quot;yourcomboname&quot;) %>
<select name=&quot;yourcomboname&quot;%>
<option value=&quot;value&quot;<%If yourvar = value then response.write(&quot; selected&quot;)%>Option text</option>
</select>

Obviously, you need to do this for each option, but if you are creating it from a recordset then it won't be a problem.

Be advised though that you will be told off for not using javascript to repopulate your second combo!
Derren
[Mediocre talent - spread really thin]
 
Hi

When you submit the form, is the submit from the form with the first combo box in it? If it is the value of the combo box that you have selected will be passed as a form parameter. Then you can reselect the value in the combo box on the new page using this:

Code:
<% yourvar = request.form(&quot;yourcomboname&quot;) %>
<select name=&quot;yourcomboname&quot;%>
<option value=&quot;value&quot;<%If yourvar = value then response.write(&quot; selected&quot;)%>>Option text</option>
</select>

Obviously, you need to do this for each option, but if you are creating it from a recordset then it won't be a problem.

Be advised though that you will be told off for not using javascript to repopulate your second combo!
Derren
[Mediocre talent - spread really thin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top