PineRest
06-19-2006, 09:06 AM
Hello. I have a cookie that sets a value called "type". I have a database that stores the values in a form's Select field. I'd like the form to write 'selected' when the value in the cookie matches the value in the database.
(Example: The select values in the database are car, boat, airplane. The cookie stored is boat. So the form's select options should have 'selected' in the boat option.)
Here's the code I have (FYI, the cookie is storing the correct value):
<select name="EVE_TYPE" class="form" onBlur="XMwriteCookie('Type',MM_findObj('EVE_TYPE').value,1)" id="EVE_TYPE">
<%
While (NOT rsType.EOF)
%>
<option value="<%=(rsType.Fields.Item("TYPE_ID").Value)%>" <%If (rsType.Fields.Item("TYPE_ID").Value)= Request.Cookies("Type") Then Response.Write " selected"%>><%=(rsType.Fields.Item("TYPE_NAME").Value)%></option>
<%
rsType.MoveNext()
Wend
If (rsType.CursorType > 0) Then
rsType.MoveFirst
Else
rsType.Requery
End If
%>
</select>
(Example: The select values in the database are car, boat, airplane. The cookie stored is boat. So the form's select options should have 'selected' in the boat option.)
Here's the code I have (FYI, the cookie is storing the correct value):
<select name="EVE_TYPE" class="form" onBlur="XMwriteCookie('Type',MM_findObj('EVE_TYPE').value,1)" id="EVE_TYPE">
<%
While (NOT rsType.EOF)
%>
<option value="<%=(rsType.Fields.Item("TYPE_ID").Value)%>" <%If (rsType.Fields.Item("TYPE_ID").Value)= Request.Cookies("Type") Then Response.Write " selected"%>><%=(rsType.Fields.Item("TYPE_NAME").Value)%></option>
<%
rsType.MoveNext()
Wend
If (rsType.CursorType > 0) Then
rsType.MoveFirst
Else
rsType.Requery
End If
%>
</select>