Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access both value and text in dropdown list

Status
Not open for further replies.

lin73

Programmer
Feb 17, 2006
110
SE
Hi

I have a dropdown list with names and id's like this..

Code:
<select name="SelectCust" class="LicenseFieldLong">
<option value="0">Select Customer</option>
<option value="1">Name 1</option>
<option value="2">Name 2</option>
</select>

I know I get the value by Request.Form("SelectCust")
But how do I get the text?

Regards

 
The text is not passed in the Request, if the text is stored in the DB you can do a SQL lookup to get it, otherwise you can add some additional form fields and use Javascript on the client side to populate the text into these fields on Submit of the form.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005
 
or you can also put the text in the value: something like this:
Code:
<select name="SelectCust" class="LicenseFieldLong">
<option value="0$Select Customer">Select Customer</option>
<option value="1$Name 1">Name 1</option>
<option value="2$Name 2">Name 2</option>
</select>

I have just used the symbol $ to separate the value and text fields...

then you can retrieve the value and text as follows:

dim myarray = Split(request.form("SelectCust"),"$")

response.write "the value is: " & myaaray(0)
response.write "the text is: " & myaaray(1)

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top