How can I read <select> contents on the server?

C

Christina

I want to read a classic HTML Form using the ASP Request object on the
server. This is a common approach. But how can I read all the contents of a
listbox (the <select> tag)?


Best regards,
Christina
 
R

Ray at

When the form is posted, the only data that is passed from the <select> is
what is selected. Options:

Use client side script to select all the elements onsubmit. (not 100%
reliable)

If your select is generated by your ASP code, use the same logic to
regenerate the list again. If this is not an option, use a hidden input(s)
and have it contain the same data that is in the <select>.

Ray at work
 
A

Aaron Bertrand - MVP

You could put all the contents of the <select> in a hidden input type.
However, how are you building the <select> list? Isn't it static? If so,
you don't need to read it every time a user submits a form.
 
C

Christina

How do I select the elements on exit? And how do I read them on the server?

The form is submitted by the user after he/she has modified the contents of
the listbox (by adding items from another listbox)


Best ones,
Christina
 
R

Ray at

Christina said:
How do I select the elements on exit?

This I am not sure about. Try inquiring in a javascript group. I believe
you have to loop through all the options and mark them as selected.
And how do I read them on the server?

theVals = Request.Form("TheNameOfTheSelect")

The form is submitted by the user after he/she has modified the contents of
the listbox (by adding items from another listbox)

I see. Then, well, that at least tells you that the user's browser supports
javascript, so I'd go either do the "select all on submit" or possibly
better, add something to the same client-side function that is entering the
new values in the select that will also add the values to a hidden input.

Ray at work
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top