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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with selected option in drop down

Status
Not open for further replies.

dommett

Programmer
Apr 30, 2004
33
US
I have a form with a drop down box that calles the page it is on (business.asp) with the selected value. The call (URL) is fine but once the page reloads, it never has the selected category "selected".

Here's the code:

intCategoryID = Request.QueryString("SelectedCategory")
<form name="frmCategoryName" method="Put" action="businesses.asp">
What category of business do you want to see? <SELECT size="1" name="SelectedCategory" onchange=frmCategoryName.submit()>
<%
Do While not rsCategories.EOF
If intCategoryID = rsCategories("ID") then
Response.Write ("<option value=" & rsCategories("ID") & "selected>" & rsCategories("CategoryName") & "</option>")

else
Response.Write ("<option value=" & rsCategories("ID") & ">" & rsCategories("CategoryName") & "</option>")
end if
rsCategories.MoveNext
Loop
rsCategories.Close
%>
</SELECT></form>


The red line above never gets executed. I have confirmed that intCategoryID holds a valid ID and that it does indeed match a rsCategory("ID"). When I make a selection from the drop down box, my address changes appropriately but the value selected in the drop down box always goes back to the the first available option.
 
Try putting a space in there before your word Selected

it looks like it is getting mashed up against the value from your recordset.

like this:
Response.Write ("<option value=" & rsCategories("ID") & " selected>" & rsCategories("CategoryName") & "</option>")


I don't know if that is the problem you see yet but it will be a problem eventually.
 
Oh my gosh!! That was it - how embarrasing. Thanks!!!
 
No problem, sometimes you just need a second pair of eyes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top