Forum Moderators: open

Message Too Old, No Replies

<select> passing to PHP

multiple selections

         

Jillian

4:42 pm on Feb 18, 2005 (gmt 0)



I'm looking for a way to select multiple <option> and pass them through toanother .php page.

Also, a way to have a fill-in area in an option area. This would enable someome to fill in as well as pick an option

Thanks,
Jillian

dcrombie

5:02 pm on Feb 18, 2005 (gmt 0)



The first one is easy:

<SELECT multiple name="selection[]"> 
<OPTION>value 1</OPTION>
<OPTION>value 2</OPTION>
<OPTION>value 3</OPTION>
</SELECT>

this shows up after form submission as an array.

There's no clean way to to the second - various threads on this site talk about using JavaScript to show/hide the option list and a textbox but you're better off IMHO having the option list followed by an input box for 'Other' values.

jonesehh

5:32 pm on Feb 18, 2005 (gmt 0)

10+ Year Member


My understanding was that you just used

<select name="whatever" multiple>

then gave each option it's own name eg

<option name="option1">Option 1</option>
<option name="option2">Option 2</option>

The form returns option1 = TRUE if selected,

Unfortunately, I tried this and it didn't work. Using the get method I just got

url?whatever=option+1&whatever=option+2

There must be a way but to be honest, can't you just use check boxes? This negates the user's need to ctrl+click for each option so would be better for usability.

Nick