469,362 Members | 2,295 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

Text Value of DropDown box

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


Apr 19 '06 #1
3 20730

Bhaskar Reddy wrote:
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>

--
Mike Brind

Apr 19 '06 #2
Bhaskar Reddy wrote:
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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Apr 19 '06 #3
Bob Barrows [MVP] wrote:
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?

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Apr 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by hans.bonefaas | last post: by
8 posts views Thread by Radek Budař | last post: by
7 posts views Thread by Brad Pears | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.