RE: [PHP] Multiple select box and form submitting
| From: | Johnson, Kirk | Date: | Mon, 07 May 2001 20:45:12 +0000 |
| Subject: | RE: [PHP] Multiple select box and form submitting | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-51830@lists.php.net to get a copy of this message | ||
Use empty brackets in the name attribute, e.g., <SELECT NAME="form[]"
MULTIPLE>. PHP will then create an array indexed by numbers. PHP will
automatically assign indices in assignments if you omit the index:
<?
$array[] = "foo";
$array[] = "bar";
echo $array[0]."<br>";
echo $array[1]."<br>";
?>
Kirk
> -----Original Message-----
> From: ..s.c.o.t.t.. [gts] [mailto:scott@graphictype.com]
> Subject: [PHP] Multiple select box and form submitting
>
> i've got a multiple select on a form and want to
> find out *all* selected values.
>
> the form looks like so:
>
> <SELECT NAME="form[category]" MULTIPLE>
> <OPTION VALUE="0">First
> <OPTION VALUE="1">Second
> <OPTION VALUE="2">Third
> </SELECT>
>
> when the form submits, $form['category'] is not
> an array of selected values, but rather a single
> value. even if i select two or three things,
> $form['category'] is still one value. can
> anyone tell me how to get a list of all selected
> values in the box?