Skip to content

Instantly share code, notes, and snippets.

@ildarkhasanshin
Forked from southern-hu/form.html
Created February 15, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ildarkhasanshin/bfb6a55b1e6b2f099c903ad2b2d8a12c to your computer and use it in GitHub Desktop.
Save ildarkhasanshin/bfb6a55b1e6b2f099c903ad2b2d8a12c to your computer and use it in GitHub Desktop.
HTML Multi checkbox set – the correct way to group checkboxes http://www.wastedpotential.com/html-multi-checkbox-set-the-correct-way-to-group-checkboxes/
<input type="checkbox" name="chk_group[]" value="value1" />Value 1<br />
<input type="checkbox" name="chk_group[]" value="value2" />Value 2<br />
<input type="checkbox" name="chk_group[]" value="value3" />Value 3<br />
<?php
if (isset($_POST['chk_group'])) {
$optionArray = $_POST['chk_group'];
for ($i=0; $i<count($optionArray); $i++) {
echo $optionArray[$i]."<br />";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment