lindm Posted May 11, 2008 Share Posted May 11, 2008 I have 6 checkboxes. Is there an easy way to check if any 2 of them or more are checked? if (2 or more checkboxes are checked) return xxx; Thanks Link to comment https://forums.phpfreaks.com/topic/105171-verify-if-checkboxes-are-checked/ Share on other sites More sharing options...
AndyB Posted May 11, 2008 Share Posted May 11, 2008 Yes ... but exact details depend on your form code. If the checkboxes are named as array elements, you can check the size of the array retrieved from the $_POST/$_GET array for the checkbox variable Link to comment https://forums.phpfreaks.com/topic/105171-verify-if-checkboxes-are-checked/#findComment-538478 Share on other sites More sharing options...
wildteen88 Posted May 11, 2008 Share Posted May 11, 2008 When checkboxes are checked your browser will include it in the $_POST data (or $_GET date depending on your forms submit method). So just check to make your checkbox field exists eg: if(isset($_POST['chk_box_name']) && !empty($_POST['chk_box_name'])) { echo 'chk_box_name was checked!'; } Link to comment https://forums.phpfreaks.com/topic/105171-verify-if-checkboxes-are-checked/#findComment-538480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.