Connecting Tech Pros Worldwide Forums | Help | Site Map

Checking For Checkbox Array

Steve
Guest
 
Posts: n/a
#1: Jul 17 '05
I'm working on a page for an e-commerce site that has a form than lists items in an order placed by a customer. The form serves two purposes: to edit
and save the details of the items (i.e. number of items, price, etc.) and to split the order (i.e. select certain items to remove from the order and
use to create a new separate order). Each item has a checkbox next to it, and the name for the checkbox is "name[]" so an array of the checked items
is created and passed to the processing script. The logic I want to use to determine if the items are being saved or being split out is by looking at
the $name array. However, if I try something like "if ($_POST['name'])" and none of the checkboxes are checked, I get an Undefined Index error (it
works fine if there are items checked). What is a valid way to check to see if the $name array exists so I know which action to take?

Thanks.

Steve

Brion Vibber
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Checking For Checkbox Array


Steve wrote:[color=blue]
> What is a valid way to check to see if the $name array
> exists so I know which action to take?[/color]

http://www.php.net/isset

-- brion vibber (brion @ pobox.com)
Steve
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Checking For Checkbox Array


Brion Vibber wrote:[color=blue]
> Steve wrote:
>[color=green]
>> What is a valid way to check to see if the $name array exists so I
>> know which action to take?[/color]
>
>
> http://www.php.net/isset
>
> -- brion vibber (brion @ pobox.com)[/color]

Duh. Brain freeze there, I guess.

Thanks.

Steve
Closed Thread