EmperorDoom Posted August 9, 2006 Share Posted August 9, 2006 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 Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 9, 2006 Share Posted August 9, 2006 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] Quote Link to comment Share on other sites More sharing options...
poirot Posted August 9, 2006 Share Posted August 9, 2006 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. Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 9, 2006 Share Posted August 9, 2006 Ok, cool, I was just thinking, not really up on PHP :D Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 9, 2006 Share Posted August 9, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.