I have a page named Page1.asp?CID=45. This page has a drop-down menu which lists the records (FirstName & LastName) from a database table. Now what I want is when the user whose CID=45 comes to this page, in the drop-down menu, CID=45 will be selected by default. If say a user whose CID=75 comes to this page, then the drop-down menu should show CID=75 as selected by default i.e. depending on the CID value retrieved from the querystring, the drop-down menu will change the default selected option. This is what I am doing to accomplish this:
But the above code doesn't select by default that option in the drop-down menu which is the value of the querystring CID. What is wrong with the above code?
Thanks,
Arpan
Code:
<%
Dim objConn,objRS,strSQL
Set objConn=CreateObject("ADODB.CONNECTION")
..............
Set objRS=CreateObject("ADODB.RECORDSET")
strSQL="SELECT * FROM DBTable"
objRS.Open strSQL,objConn
%>
<select name="contacts">
<%
Do Until(objRS.EOF)
If(objRS("ContactID")=Request("CID")) Then
%>
<option value="<%= objRS("ContactID") %>"
Code:
selected
Code:
><%= objRS("FirstName") & " " & objRS("LastName") %></option>
<%
Else
%>
<option value="<%= objRS("ContactID") %>"><%= objRS("FirstName") & " " & objRS("LastName") %></option>
<%
End If
objRS.MoveNext
Loop
%>
</select>
But the above code doesn't select by default that option in the drop-down menu which is the value of the querystring CID. What is wrong with the above code?
Thanks,
Arpan