faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 9 people (56%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

is there a way to pass all the options in a select box, not just the currently selected one?

Apr 21st, 2005 08:10
Kevin Jackson, Narendra Jain, Chris Betts,


There is no way to pass the unchecked / unselected values from a select
box. Only the selected data is passed over by the form.
==========================================================================
If the user has not disabled Javascript, you can do the following:
1) Add an empty, hidden input to your form.
2) As part of your validation process (immediately before you actually
submit the form to the server), walk through the select you want to
save, and append the information you want to save to a javascript string
variable.
3) Set the value of your hidden field to the value of your javascript
string variable.
4) the hidden field, containing all the select's data, gets passed to
your server where you can deconstruct it and parse it however you wish.