View Full Version : checkbox

03-09-2007, 04:25 PM

I have a page that has a bunch of check boxes with different names.
Once the user presses the submit button another page opens.
In that page i am trying to write code to check which check boxes are checked on the previous page and add their names to an array.

How can i check the checkboxes from another page?
I have to do it on another page as i am waiting for the submit action to know what boxes have been checked.

Hope this makes some sense!
Any help would be appreciated!


03-09-2007, 06:08 PM
Checkboxes are a little goofy because if a checkbox is not checked, it does not carry any data across the request ($_POST or $_GET). If the checkbox is checked, it comes across just like any other form input in the $_POST or $_GET array (I believe the value is the string 'on').

03-09-2007, 08:48 PM
If you want/need a value(whether it's on or off you could use
<input type="hidden" name="checkbox" value="off" /> with the same name as the checkbox if you put it before the checkbox it will be overwritten by the checkbox if it's on, and if not you'll get "off" as the value.

03-09-2007, 09:07 PM
Hey that's a pretty good trick, hadn't heard that one before. Nice!