Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Text Value of DropDown box

Reply
Thread Tools

Text Value of DropDown box

 
 
Bhaskar Reddy
Guest
Posts: n/a
 
      04-19-2006
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




 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      04-19-2006

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

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-19-2006
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"


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      04-19-2006
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
div box questions; float text around a box, fit box to image size Gnarlodious HTML 4 05-05-2010 11:30 AM
Dynamically populate text field based on dropdown box value inColdfusion Lewis Javascript 1 11-26-2008 12:05 PM
Dynamically populate text field based on dropdown box value inColdfusion jnag Javascript 2 02-27-2008 07:47 PM
Populate text box with value from dropdown list TJHerman ASP .Net Web Controls 0 06-14-2006 05:00 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM



Advertisments