RE: [PHP] how to user <select multiple="true">
| From: | John W. Holmes | Date: | Wed, 16 Oct 2002 01:45:10 +0000 |
| Subject: | RE: [PHP] how to user <select multiple="true"> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120092@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: John W. Holmes [mailto:holmes072000@charter.net]
> Sent: Tuesday, October 15, 2002 9:36 PM
> To: 'Khalid El-Kary'; php-general@lists.php.net
> Subject: RE: [PHP] how to user <select multiple="true">
>
> > hi,
> > If i have a form that has a <select> with multiple="ture" how would
i
> be
> > able to retireve it's multiple values in the PHP script, i tried the
> > $_REQUEST['fieldname'] it gave me only the last selected value
> >
> > note: multiple selection is done by holding ctrl :)
>
> PHP will make an array for you.
>
> <select name="foo" multiple>
> <option value=1>One</option>
> <option value=2>Two</option>
> <option value=3>Three</option>
> </select>
>
> When that is submitted, you'll have a $_REQUEST['foo'][] array
created.
> If you chose One and Three, you'd have
>
> $_REQUEST['foo'][0] ==> 1
> $_REQUEST['foo'][1] ==> 3
>
> Use count($_REQUEST['foo']) to see how many items were selected.
>
> ---John Holmes...
>
Err...name it as an array. Name="foo[]"
...like others have pointed out. :)
---John Holmes...