Reading dropdown values in ASP

Reading dropdown values in ASP

am 29.03.2007 11:46:23 von Martin Walke

Hi all,

I have an ASP application where I need to not only read the selected item
from a combo box on a web page but also all the options in the combo box.
Can someone point me in the right direction.

I can obviously use request.querystring() or request.form() to get the
selected value but not sure about how to get the options.

TIA
Martin

Re: Reading dropdown values in ASP

am 29.03.2007 12:43:04 von reb01501

Martin Walke wrote:
> Hi all,
>
> I have an ASP application where I need to not only read the selected
> item from a combo box on a web page but also all the options in the
> combo box. Can someone point me in the right direction.
>
> I can obviously use request.querystring() or request.form() to get the
> selected value but not sure about how to get the options.
>
Obviously, you have to store the values somewhere that is accessible to the
code running on the web server. Possibilities inclued a database, a text
file, an xml file, a session variable, an application variable, or some
combination of the above.

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

Re: Reading dropdown values in ASP

am 29.03.2007 14:33:50 von reb01501

Martin Walke wrote:
> Hi all,
>
> I have an ASP application where I need to not only read the selected
> item from a combo box on a web page but also all the options in the
> combo box. Can someone point me in the right direction.
>
> I can obviously use request.querystring() or request.form() to get the
> selected value but not sure about how to get the options.
>
Oh! One possibility i neglected to mention was to use a hidden field in
the form to store the option values, making them part of the Request.

--
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: Reading dropdown values in ASP

am 29.03.2007 15:03:52 von Tim Slattery

"Martin Walke" wrote:

>Hi all,
>
>I have an ASP application where I need to not only read the selected item
>from a combo box on a web page but also all the options in the combo box.
>Can someone point me in the right direction.
>
>I can obviously use request.querystring() or request.form() to get the
>selected value but not sure about how to get the options.

You can't. When the form is submitted, one value is transmitted for a
select group: the "value" attribute of the selected option. Nothing
else is sent.

If you want to know the other options in the select group, you'll have
to do it another way: store them in a database, in the session object,
something like that. And bear in mind, that what's transmitted for the
selected option is not what the user sees, it's the "value" attribute.

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov
http://members.cox.net/slatteryt

Re: Reading dropdown values in ASP

am 29.03.2007 15:57:56 von Martin Walke

Thanks Bob.

My line of thinking was to a hidden field anyway.

I just wondered, although couldn't find any reference to it, whether the
srever could access the data in some sneaky way. Obviously, if I'd thought
it through, that client side data doesn't get transmitted in the Request.

Martin

"Bob Barrows [MVP]" wrote in message
news:eb52p4fcHHA.4772@TK2MSFTNGP05.phx.gbl...
> Martin Walke wrote:
>> Hi all,
>>
>> I have an ASP application where I need to not only read the selected
>> item from a combo box on a web page but also all the options in the
>> combo box. Can someone point me in the right direction.
>>
>> I can obviously use request.querystring() or request.form() to get the
>> selected value but not sure about how to get the options.
>>
> Oh! One possibility i neglected to mention was to use a hidden field in
> the form to store the option values, making them part of the Request.
>
> --
> 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: Reading dropdown values in ASP

am 29.03.2007 16:00:12 von Martin Walke

Thanks Tim. It was as I assumed. As per my comment to Bob, I'll use a hidden
field populated by my validate routine.

Martin


"Tim Slattery" wrote in message
news:u4en03t05pu582mtenfbq7bo5u0no3sh24@4ax.com...
> "Martin Walke" wrote:
>
>>Hi all,
>>
>>I have an ASP application where I need to not only read the selected item
>>from a combo box on a web page but also all the options in the combo box.
>>Can someone point me in the right direction.
>>
>>I can obviously use request.querystring() or request.form() to get the
>>selected value but not sure about how to get the options.
>
> You can't. When the form is submitted, one value is transmitted for a
> select group: the "value" attribute of the selected option. Nothing
> else is sent.
>
> If you want to know the other options in the select group, you'll have
> to do it another way: store them in a database, in the session object,
> something like that. And bear in mind, that what's transmitted for the
> selected option is not what the user sees, it's the "value" attribute.
>
> --
> Tim Slattery
> MS MVP(DTS)
> Slattery_T@bls.gov
> http://members.cox.net/slatteryt