jrthor2
04-25-2006, 08:52 AM
I have a select box that I am trying to get the option to be selected if my categories match from the database and the url, but I can't seem to get it working. Below is my code, so if the catg in the url = the id from the db, then I want the option to be selects.
<select id="category_id" size="1">
<%
SQLstmt = "SELECT * from Categories order by category asc"
Set rs = conn.execute(SQLstmt)
Do while NOT rs.EOF
id = rs("category")
category_nme = rs("category_description")
%>
<option value="<%=id%>"<%if (Request.QueryString("catg")) = id then%> selected <%end if%>><%= category_nme%></option>
<%
rs.MoveNext
Loop
rs.Close
Set conn = nothing
Set rs = Nothing
Set SQLstmt = nothing
%>
</select>
Thanks!
<select id="category_id" size="1">
<%
SQLstmt = "SELECT * from Categories order by category asc"
Set rs = conn.execute(SQLstmt)
Do while NOT rs.EOF
id = rs("category")
category_nme = rs("category_description")
%>
<option value="<%=id%>"<%if (Request.QueryString("catg")) = id then%> selected <%end if%>><%= category_nme%></option>
<%
rs.MoveNext
Loop
rs.Close
Set conn = nothing
Set rs = Nothing
Set SQLstmt = nothing
%>
</select>
Thanks!