I thought this was a simple task to do, but not.
I just want the option stay selected when a value from the session variable exists, AND it does after the form has been submitted. So why can't the option value stay selected as long as session is populated.
If I put a static value in the loop like this:
If RegID = 5 Then ...
Then the option stays selected at this post.
SQL = "SELECT * FROM tbregion ORDER BY region ASC"
Set RS = Server.CreateObject("ADODB.recordset")
RS.Open SQL,Conn
Session("region") = Request.Form("regv")
region = Session("region")
%>
<form name="region" action="select_menu.asp" method="post">
<select name="regv" onchange="region.submit()">
<option value="">Make a selection</option>
<option value="">------------------</option>
<%
RegID = RS("regionID")
x=0
Do While Not RS.EOF
If RegID = region Then
For i = 1 To Region
Response.Write("<option value='" & RS("regionID") & "' SELECTED>" & RS("region") & "</option>")
x=x+1
Next
Else
x=x -1
For i = 1 To RegID
Response.Write("<option value='" & RS("regionID") & "'>" & RS("region") & "</option>")
Next
End If
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
%>
</select>
</form>
<%
Response.Write("<a href='category.asp?clevel=1®v="& region & "'>Link</a>")
%>