Getting option"s text value

Getting option"s text value

am 10.04.2007 22:13:51 von aljamala

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!

Re: Getting option"s text value

am 10.04.2007 22:59:26 von Adrienne Boswell

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:

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

Re: Getting option"s text value

am 11.04.2007 02:55:56 von Dave Anderson

"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!





--
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.

Re: Getting option"s text value

am 11.04.2007 08:00:55 von vinodkus

On 10 Apr, 13:13, "Raul" wrote:
> 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










PrintSelectList.asp

<%
dim strSelect
dim i
strSelect = split(Request.Form("cboToppings"), ", ")
length = len(str)
for i = 0 to UBound(strSelect)
response.write strSelect(i) & " "
next
%>

Re: Getting option"s text value

am 13.04.2007 19:33:32 von aljamala

On Apr 11, 2:00 am, vinod...@gmail.com wrote:
> select.asp
>
>


>
>


>
>


>

>
>
> PrintSelectList.asp
>
> <%
> dim strSelect
> dim i
> strSelect = split(Request.Form("cboToppings"), ", ")
> length = len(str)
> for i = 0 to UBound(strSelect)
> response.write strSelect(i) & " "
> next
> %>
>

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!

Re: Getting option"s text value

am 13.04.2007 20:00:17 von reb01501

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.

Re: Getting option"s text value

am 13.04.2007 20:52:49 von aljamala

On Apr 13, 2:00 pm, "Bob Barrows [MVP]"
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?

Re: Getting option"s text value

am 13.04.2007 21:34:36 von Dave Anderson

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.

Re: Getting option"s text value

am 13.04.2007 21:45:46 von Dave Anderson

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.