Re: multiple checkboxes
| From: | José de Paula | Date: | Mon, 02 Aug 2004 20:32:44 +0000 |
| Subject: | Re: multiple checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192500@lists.php.net to get a copy of this message | ||
On Mon, 2 Aug 2004 15:21:31 -0500, Josh Close <narshe@gmail.com> wrote:
> Very simple question.....
>
> When making multiple checkboxes, you put the name the same for a few
> to group them together
>
> <form action="process.php" method="post">
> <input type="checkbox" name="checkBoxGroup" value="first"
> />
> <input type="checkbox" name="checkBoxGruop" value="second"
> />
> </form>
>
> So they are grouped.... but then submitting them I only get the last
> value check.
>
> <? print_r($_POST); ?>
>
> How would I get all the boxes check when "grouping" them by using the
> same name for all checkboxes in the name field?
I've used
<form action="process.php" method="post">
<input type="checkbox" name="checkBoxGroup[]" value="first"
/>
<input type="checkbox" name="checkBoxGruop[]" value="second"
/>
</form>
in a similar situation.
You can then manipulate the $_POST['checkBoxGroup'] array just like
any other PHP array.