<input type="checkbox" class='form' name="checkbox_1" />
<input type="checkbox" class='form' name="checkbox_2" />
<input type="checkbox" class='form' name="checkbox_3" />
.........
<input type="checkbox" class='form' name="checkbox_10" />
The from has been submitted using the "POST" method. identify, which of the check-boxes and write their numbers in increasing order. Separated all numbers by spaces(not new lines) and do not use any HTML formatting.
For Eg:
If check-boxes 3, 5 and 10 are checked.
Ouput would be:
3 5 10
A checkbox allows you to select single values for submission in a form (or not).
In the PHP script (checkbox-form. php), we can get the submitted option from the $_POST array. If $_POST['formWheelchair'] is “Yes”, then the box was checked. If the check box was not checked, $_POST['formWheelchair'] won't be set.
Change the markup to something like
<input type="checkbox" class='form' value="1" name="checkbox[]" />
<input type="checkbox" class='form' value="2" name="checkbox[]" />
<input type="checkbox" class='form' value="3" name="checkbox[]" />
and to get the values submitted, use a simple loop
foreach($_POST['checkbox'] as $checkbox){
echo $checkbox . ' ';
}
HTML Code ::
<input type="checkbox" name="arrayValue[]" value="value1" > value1 <br />
<input type="checkbox" name="arrayValue[]" value="value2" > value2 <br />
<input type="checkbox" name="arrayValue[]" value="value3" > value3 <br />
<input type="checkbox" name="arrayValue[]" value="value4" > value4 <br />
php code::
$checkBoxValue = join(", ", $_POST['arrayValue']); // here first (,) is user-define
// means, you can change it whatever
// you want, even if it can be (space) or others
now you get the whole value of 'checkbox' in one variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With