Jump to content

Multiple Checkbox W/ Same Name


jgingras

Recommended Posts

Hi, im having a problem with a page that has multiple checkboxes with the same name. When I do $_REQUEST["CheckBoxname"], it only returns the last checkbox checked. How can I walk through all of the check boxes in PHP?

 

Thanks,

-jacques

Edited by jgingras
Link to comment
Share on other sites

The first step is to make sure your form is actually passing an array of checkbox values to your PHP script. In your form, your checkboxes should have name="CheckBoxname[]" (not just name="CheckBoxname") to indicate they are part of an array.

 

Once the form is passing an array correctly, it should be relatively easy to have your script iterate through the array's values.

Link to comment
Share on other sites

The first step is to make sure your form is actually passing an array of checkbox values to your PHP script. In your form, your checkboxes should have name="CheckBoxname[]" (not just name="CheckBoxname") to indicate they are part of an array.

 

Once the form is passing an array correctly, it should be relatively easy to have your script iterate through the array's values.

 

thanks a lot Dave! that worked great! :)

 

 

-jacques

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...