ullenulle
asked on
Preselect a value in a dropdownmenu based on a query-string.
Hi there.
I have a SELECT-menu that pulls values from a MySQL-database. I want this particular menu to be populated with a query-string. So far I just added another OPTION VALUE-line, but that's kinda "cheat", since the query-value will be there twice. Any suggestions how to do it more correctly? :-)
Here's my code so far:
Best regards
Ullenulle
I have a SELECT-menu that pulls values from a MySQL-database. I want this particular menu to be populated with a query-string. So far I just added another OPTION VALUE-line, but that's kinda "cheat", since the query-value will be there twice. Any suggestions how to do it more correctly? :-)
Here's my code so far:
<select name="samarbejdspartner_expense" id="samarbejdspartner_expense" onChange="reload()">
<option value="null" <%If (Not isNull((Recordset1.Fields.Item("samarbejdspartner_expense").Value))) Then If ("null" = CStr((Recordset1.Fields.Item("samarbejdspartner_expense").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>></option>
<option value="Request.QueryString("partner")" <%If (Not isNull(Request.QueryString("partner"))) Then If (Request.QueryString("partner") = CStr(Request.QueryString("partner"))) Then Response.Write("selected=""selected""") : Response.Write("")%>><%=(Request.QueryString("partner"))%></option>
<%
While (NOT Recordset3.EOF)
%>
<option value="<%=(Recordset3.Fields.Item("partner_navn").Value)%>" <%If (Not isNull((Recordset1.Fields.Item("samarbejdspartner_expense").Value))) Then If (CStr(Recordset3.Fields.Item("partner_navn").Value) = CStr((Recordset1.Fields.Item("samarbejdspartner_expense").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Recordset3.Fields.Item("partner_navn").Value)%></option>
<%
Recordset3.MoveNext()
Wend
If (Recordset3.CursorType > 0) Then
Recordset3.MoveFirst
Else
Recordset3.Requery
End If
%>
</select>
Best regards
Ullenulle
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER