Re: How to handle multiple value checkboxes
| From: | Kevin Stone | Date: | Thu, 29 Aug 2002 21:38:12 +0000 |
| Subject: | Re: How to handle multiple value checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114552@lists.php.net to get a copy of this message | ||
<form method="post" action="formhandler.php">
<input type="checkbox" name="colors[]" value="red">
<input type="checkbox" name="colors[]" value="green">
<input type="checkbox" name="colors[]" value="blue">
</form>
This creates the indexed array $_POST['colors']. The array will only have
as many values as were checked. In otherwords if Red and Blue are checked
the values will be reutnred at $_POST['colors'][0] and $_POST['colors'][1]..
not at index [0] and [2] as you might expect.
Hope this helps,
Kevin
----- Original Message -----
From: "Lon Lentz" <lonl@eximpact.com>
To: "Php-General@Lists. Php. Net" <php-general@lists.php.net>
Sent: Thursday, August 29, 2002 3:07 PM
Subject: [PHP] How to handle multiple value checkboxes
>
>
> If I have a form with multiple checkboxes with different values but the
> same name, and someone selects a couple of them, how do I reference all of
> the values? Right now I am only getting the last one selected.
>
>
>
> __________________________
> Lon Lentz
> Applications Developer
> EXImpact.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>