Jump to content

Archived

This topic is now archived and is closed to further replies.

EmperorDoom

Checkbox Help

Recommended Posts

Hey guys, I need help with this one:
I have a form set up with checkboxes. I know how to get an array of the boxes that were checked, but is there anyway to get an array of the boxes that were unchecked? (as in the user clicked them off after they were already checked when the form loaded)
Thanks

Share this post


Link to post
Share on other sites
I'm not sure of the validation you're using, or how one would go about checking if a box was checked, but if the code involved (Pseudo-code here:)

[code]if(box_is_checked);[/code]

could you not just add an '!'

[code]if(!box_is_checked);[/code]

Share this post


Link to post
Share on other sites
No, you can't. Only checked checkboxes are submitted, so if you want to know which were left unchecked, your script must know what checkboxes exist.

Share this post


Link to post
Share on other sites
That will not work, since only those checkboxes that are checked are returned to your script.

You could set up an array of all possible checkbox names and then check if the names are set in $_POST, if the name isn't set, the check box wasn't checked.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.