Reading dropdown values in ASP

M

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
 
B

Bob Barrows [MVP]

Martin said:
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.
 
B

Bob Barrows [MVP]

Martin said:
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.
 
T

Tim Slattery

Martin Walke said:
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.
 
M

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
 
M

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top