RE: [PHP] Sending Form Arrays
| From: | Matt Schroebel | Date: | Mon, 28 Jan 2002 14:43:14 +0000 |
| Subject: | RE: [PHP] Sending Form Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-82408@lists.php.net to get a copy of this message | ||
What I do is:
<input type="checkbox" name="check[]" value="Box 1">Box
1<BR>
<input type="checkbox" name="check[]" value="Box 2">Box
2<BR>
<input type="checkbox" name="check[]" value="Box 3">Box
3<BR>
<input type="checkbox" name="check[]" value="Box 4">Box
4<BR>
<input type="checkbox" name="check[]" value="Box 5">Box
5<BR>
Then in the action script you'll get an array with only the checked values named $checked. So
$checked[0] could be 'Box 2' and $checked[1] could be 'Box 5'. Be aware if
nothing is checked, then $checked won't be an array, so you'll need
to test with is_array($checked) before referencing it with, say, foreach.
> From: "Scott Saraniero" <Scottsar@aminternet.com>
> Hi,
>
> I have a form that has a section with multiple checkboxes. I would
> like to be able to send the checked boxes out as an array, and be
> able to retrieve the array in the next page (that the form variables
> go to.) I cannot find specific info on this anywhere. Can someone
> please point me in the right direction?
>