ajetrumpet Posted November 21, 2019 Share Posted November 21, 2019 guys, I have looked on google for this and apparently noone is doing it. I have 4 checkboxes and I want to send mail indicating which boxes were checked. the only code I've found is PHP that captures the *status* of the boxes, such as "on" or "off". I want to capture the names of the actual checkbox elements. Here is the code I'm currently testing (which just prints out "on" or "off" to indicate which boxes are checked): if(isset($_POST['checkboxes'])) { foreach($_POST['checkboxes'] as $selected){ echo $selected . "</br>"; } } else { echo "No Desired Contact Time Specified."; } if I check all 4 boxes for instance, I get this: on on on on any way to get the names? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/309558-capturing-multiple-checkboxes-names-when-submitting-form/ Share on other sites More sharing options...
requinix Posted November 21, 2019 Share Posted November 21, 2019 <input type="checkbox" name="checkboxes[]" value="whatever you want"> 1 Quote Link to comment https://forums.phpfreaks.com/topic/309558-capturing-multiple-checkboxes-names-when-submitting-form/#findComment-1571755 Share on other sites More sharing options...
ajetrumpet Posted November 21, 2019 Author Share Posted November 21, 2019 (edited) stupid me. thanks Req. small issue i know. Edited November 21, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309558-capturing-multiple-checkboxes-names-when-submitting-form/#findComment-1571756 Share on other sites More sharing options...
Barand Posted November 21, 2019 Share Posted November 21, 2019 5 hours ago, ajetrumpet said: Here is the code I'm currently testing (which just prints out "on" or "off" to indicate which boxes are checked): I'm curious to know how that posted code outputs any settings with "off" (unchecked checkboxes aren't posted) Quote Link to comment https://forums.phpfreaks.com/topic/309558-capturing-multiple-checkboxes-names-when-submitting-form/#findComment-1571760 Share on other sites More sharing options...
requinix Posted November 21, 2019 Share Posted November 21, 2019 26 minutes ago, Barand said: I'm curious to know how that posted code outputs any settings with "off" (unchecked checkboxes aren't posted) (coughitdoesnt) Quote Link to comment https://forums.phpfreaks.com/topic/309558-capturing-multiple-checkboxes-names-when-submitting-form/#findComment-1571762 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.