
Originally Posted by
smita86
i have taken the combo box data from a table. I have made the below code.Please guide how to change the below data.
<% SQL ="Select City From City order By City"
Set rs = sconn.Execute(SQL)%>
<select name="Location" size="1">
<option >- Select -</option>
<%while not rs.EOF%>
<option value=<%=rs(0)%>><%=rs(0)%></option>
<%RS.MoveNext
wend%>
</select>
Well ulthane has provided the conditional logic to do the trick but we need to know which city we are viewing... Have you passed that through a querystring argument or is it an ID that we pull from the database?
Assuming we know what city we are viewing and put that value in a variable called varCity You need to use it in your code as follows:
Code:
<%
varCity = 'The city we're looking at
varSelected = "" 'This is just the string we use to bookmark the drop down
%>
<%while not rs.EOF%>
<%
if varCity = rs(0) then
varSelected = "selected = ""selected"""
end if
%>
<option <%=varSelected%> value=<%=rs(0)%>><%=rs(0)%></option>
<%
varSelected = ""
RS.MoveNext
wend
%>
Bookmarks