Text Value of DropDown box

B

Bhaskar Reddy

Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>


I need the text value of the drop down box.

Request.form("drp1").value is giving 1 , but I need the value "One". How can
I do this.

Please Help.

Thanks
 
M

Mike Brind

Bhaskar said:
Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>


I need the text value of the drop down box.

Request.form("drp1").value is giving 1 , but I need the value "One". How can
I do this.

Please Help.

Thanks

You could do this:
<select id="drp1">
<option value="One">One</option>
<option value="Two">Two</option>
</select>

Or this:
<select id="drp1">
<option>One</option>
<option>Two</option>
</select>
 
B

Bob Barrows [MVP]

Bhaskar said:
Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>


I need the text value of the drop down box.

Request.form("drp1").value is giving 1 , but I need the value "One".
How can I do this.

Please Help.
As you have seen, only the value property gets passed via the Request
object.

This is not the first time I've seen this question, and frankly, I'm a
little puzzled by it: aren't you in control of the source of those
value-text pairs? Why can't you simply retrieve the text from the data
source based on the passed value? I suppose you could be using some
client-side data source for the option list ... ?

Anyways, you have a few options:

Make the text be part of the value when populating the options:
<option value="1 - One">One
allowing you to use Split() to retrieve both values from
request.form("drp1")

Use client-side code to populate a hidden field when the form is submitted
(see a client-side group such as .scripting.jscript for this).

Store the value-text pairs in an xml document on the web server, either in a
file or in a session variable
 
D

Dave Anderson

Bob said:
This is not the first time I've seen this question, and
frankly, I'm a little puzzled by it: aren't you in control
of the source of those value-text pairs? Why can't you
simply retrieve the text from the data source based on the
passed value?

Or simply: What is the point of a value that differs from the text if you
want the text?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top