galvin Posted October 21, 2009 Share Posted October 21, 2009 If you have a form with several checkbox options like... <input type='checkbox' class="" name='pooloptions[]' value="one" />1 <input type='checkbox' class="" name='pooloptions[]' value="two" />2 <input type='checkbox' class="" name='pooloptions[]' value="three" />3 <input type='checkbox' class="" name='pooloptions[]' value="four" />4 ... and the form is submitted, you obviously have an array called "pooloptions[]' that holds the value of all options that were checked. But if I want to say, for example, "If the checkbox option with a value of "two" was NOT checked, do this, else, if the option with a value of "two" WAS checked, do this", how would I do that? I know it's simple but I'm confusing myself :-\ Thanks, Greg Link to comment https://forums.phpfreaks.com/topic/178415-solved-checking-to-see-if-checkbox-option-was-checked-or-not/ Share on other sites More sharing options...
mikesta707 Posted October 21, 2009 Share Posted October 21, 2009 check boxes that aren't checked don't get submit to the $_POST array you can do something like <input type='checkbox' class="" name='pooloptions[1]' value="one" />1 <input type='checkbox' class="" name='pooloptions[2]' value="two" />2 <input type='checkbox' class="" name='pooloptions[3]' value="three" />3 <input type='checkbox' class="" name='pooloptions[4]' value="four" />4 then you could do if (isset($_POST['pooloptions'][2])){ //do whatever } Link to comment https://forums.phpfreaks.com/topic/178415-solved-checking-to-see-if-checkbox-option-was-checked-or-not/#findComment-940868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.