Avatar of ullenulle
ullenulleFlag for United States of America

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:

<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>

Open in new window


Best regards

Ullenulle
ASP

Avatar of undefined
Last Comment
ullenulle
SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of prajapati84
prajapati84
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of ullenulle
ullenulle
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of ullenulle
ullenulle
Flag of United States of America image

ASKER

I found out the solution on my own... but thanks for your attention. :-)
ASP
ASP

Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.

82K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo