Re: Is there a way to get multiple values for a single input in a form submission?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Set the name of your field in html to be;

name="myselect[]"

that way when the form is returned to you each selected value is returned to you, for example if you code

$choices = $_POST["myselect"];

choices will be an array containing the actual values selected when the form is submitted.

hope this is what you were looking for.

Warren Vail

At 02:44 PM 3/21/2006, mslemko wrote:
this is what I am trying to do:

On a web form I might have a select input with multiple selections enabled, however I want to have access to the list within PHP after submission.

<select multiple='true' name='myselect'>
 <option value='1'>1</option>
 <option value='2'>2</option>
</select>

so when this is submitted, I can see in the $HTTP_RAW_POST_DATA that myselect is submitted twice...
...&myselect=1&myselect=2&...

However, the $_POST array only has the last value eg.
$_POST['myselect'] == '2'
This makes sense because the last value is assigned to the key 'myselect'.

Is there a function or alternate way that will get an array back from the post-back without parsing through the $HTTP_RAW_POST_DATA (which is not always available since the php.ini file can turn it off)?

TIA
-MS

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux