Page 1 of 1

<select multiple> and /return/ multiple variables...?

Posted: Sat Sep 24, 2005 2:03 pm
by Skara
Ok... I'm kinda confused.
I need a good way to select multiple categories and when they're submitted, parse them. I plan on having a few dozen categories, so checkboxes would be cumbersome to say the least.
Now I thought that a <select multiple> tag would let me actually return more than one answer, but hell if I can figure out how.

Erhm... in other words, I need something like this:

Code: Select all

<select multiple='multiple' name='cats'>
<option>one</option>
<option>two</option>
<option>three</option>
</select>
Where I can actually select more than one option and it will actually return more than one option.

As it stands, the above will only return the highest--lowest in the code--option selected.

What am I missing?

Edit: It works fine in $_GET, but not $_POST, which is most certainly what I'm going to need. :/

Posted: Sat Sep 24, 2005 2:16 pm
by Burrito
you need to make the select an array:

ex:

Code: Select all

<select multiple="multiple" name="cats[]"> 
<option value="one">one</option> 
<option value="two">two</option> 
<option value="three">three</option> 
</select>
then handle the array on the other side...

Posted: Sat Sep 24, 2005 2:32 pm
by Skara
voila, problem solved. Thanks.

I'm already using an array, so that makes yet another 2d array to parse. ^^;