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

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

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
you don't.
You can only get the item(s) that was/were selected, and then only the
"value" not the "text"

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Christina" <ha********@hotmail.con> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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

Jul 19 '05 #2

P: n/a
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

"Christina" <ha********@hotmail.con> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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

Jul 19 '05 #3

P: n/a
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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Christina" <ha********@hotmail.con> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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

Jul 19 '05 #4

P: n/a
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

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
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

"Christina" <ha********@hotmail.con> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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


Jul 19 '05 #5

P: n/a

"Christina" <ha********@hotmail.con> wrote in message
news:O3*************@TK2MSFTNGP10.phx.gbl...
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
Jul 19 '05 #6

P: n/a
"Christina" <ha********@hotmail.con> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
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)?


When the form is submitted, only the controls that that are "successful"
(http://www.w3.org/TR/html4/interact/...ssful-controls) are
submitted. With a select element, only the selected options are successful.
If more than one of the items was selected, they will be passed as a comma
separated list.

Hope this helps.
Regards,
Peter Foti
Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.