By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

Getting option's text value

P: n/a
Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(...)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated....Thanks!

Apr 10 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a

Raul wote:
Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(...)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated....Thanks!
You could append the value to the option value, eg: <option value="<
%=rsarr(0,i)%>:<%=rsarr(1,i)%>"><%=rsarr(1,i)%></option>

Then when you get the values
things = split(request.form("that"),":")
optionvalue = things(0)
textvalue = things(1)

--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share

Apr 10 '07 #2

P: n/a
"Raul" wrote:
I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(...)

However, I am wondering if you can retrieve the text value using
ASP?? I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?
Yes, you can get the desired value. Use the value submitted and query the
database for the match.
Any input would be appreciated....Thanks!
<input value="I hope this helped.">

--
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 11 '07 #3

P: n/a
On 10 Apr, 13:13, "Raul" <aljam...@gmail.comwrote:
Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(...)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated....Thanks!
select.asp
<body>
<form name = form1 method = post action = "PrintSelectList.asp">
<select name = "cboToppings" size = 4 multiple>
<option selected>Cheese
<option selected>Totmato Sauce
<option>Olive Oil
<option>Barbecue Sauce
<option>Pepperoni
<option>Sausage
<option>Mushrooms
<option>Onions
<option>Ham
<option>Pineapple
<option>Green Peppers
<option>Anchovies
</select>
<p>
<input type = submit name = cmdSubmit value = "Deliver It">
</p>
</form>
</body>
PrintSelectList.asp
<body>
<%
dim strSelect
dim i
strSelect = split(Request.Form("cboToppings"), ", ")
length = len(str)
for i = 0 to UBound(strSelect)
response.write strSelect(i) & " "
next
%>
</body>
Apr 11 '07 #4

P: n/a
On Apr 11, 2:00 am, vinod...@gmail.com wrote:
select.asp
<body>
<form name = form1 method = post action = "PrintSelectList.asp">
<select name = "cboToppings" size = 4 multiple>
<option selected>Cheese
<option selected>Totmato Sauce
<option>Olive Oil
<option>Barbecue Sauce
<option>Pepperoni
<option>Sausage
<option>Mushrooms
<option>Onions
<option>Ham
<option>Pineapple
<option>Green Peppers
<option>Anchovies
</select>
<p>
<input type = submit name = cmdSubmit value = "Deliver It">
</p>
</form>
</body>

PrintSelectList.asp
<body>
<%
dim strSelect
dim i
strSelect = split(Request.Form("cboToppings"), ", ")
length = len(str)
for i = 0 to UBound(strSelect)
response.write strSelect(i) & " "
next
%>
</body>
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it more.
Add an onclick event to the option element. Whenever it gets clicked,
save the text into a hidden form field. This value can then be used
as you like (I needed it to save the user input to the DB)

Cheers!
Apr 13 '07 #5

P: n/a
Raul wrote:
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it more.
Add an onclick event to the option element. Whenever it gets clicked,
save the text into a hidden form field. This value can then be used
as you like (I needed it to save the user input to the DB)
Sure, that's one of the ways to do this, but why do you like it better?
Now you're at the mercy of a user who can easily disable javascript in
his browser.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 13 '07 #6

P: n/a
On Apr 13, 2:00 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
Sure, that's one of the ways to do this, but why do you like it better?
Now you're at the mercy of a user who can easily disable javascript in
his browser.
Good point on that one, but I know all our users dont have JavaScript
disabled (its not a public site). If they had JavaScript disabled
then the site will not function properly.

To answer your question, I like it better because it seems more
elonquent than adding a delimiter to the value and appending the
description. Its just my opinion obviously, it is largely a stylistic
choice. Does anyone agree or am I on my own on this one?
Apr 13 '07 #7

P: n/a
Raul wrote:
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it
more. Add an onclick event to the option element. Whenever it
gets clicked, save the text into a hidden form field. This
value can then be used as you like (I needed it to save the
user input to the DB)
I fail to see how that is an improvement over getting the value from the
database. The advantage of direct DB query is especially acute if the table
you are updating is in the same database as the one you are filling options
from, since you can simply do it in the DB at insert.

--
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 13 '07 #8

P: n/a
Raul wrote:
Good point on that one, but I know all our users dont have
JavaScript disabled (its not a public site). If they had
JavaScript disabled then the site will not function properly.
You are making far too many assumptions. I, for one, run the NoScript
extension when I browse the web. With it, I can temporarily turn on
scripting for a site, get past the non-working stuff, and turn it back off.
How exactly do you think you could circumvent that?

I don't even know where to begin with the Web Developer extension. There is
almost nothing you can do client-side to prevent me from controlling the
content of my requests. You should, therefore, concentrate on handling
requests, not dictating them.

To answer your question, I like it better because it seems more
elonquent than adding a delimiter to the value and appending
the description.
In the sense that it more explicitly divides the text and value, I agree
that this is a better approach than delimited concatenation. But neither is
robust.

--
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 13 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.