check box PHP receives multiple checkbox information that is not automatically converted to an array as an ASP, which is inconvenient to use. But there is a solution, is to use JavaScript to do the preprocessing. Multiple check boxes with the same name exist in JavaScript or as an array, so you can use JavaScript to synthesize an array of characters in a check box to a hidden element in the form, and then parse the array with the EXPLODE function in PHP, before submitting the form. This enables the delivery of check box information. The following examples illustrate.
Suppose there is such a form:
1
2
3
4
This form has four names that are item check boxes, and when the user clicks the Submit button, the checker function is invoked, and if the checker returns true the form is submitted, the return false form will not be submitted. Here the checker function is the preprocessing function we want to write. Add the following JavaScript to the header portion of the HTML:
This allows you to combine the value of all selected check boxes into an array of strings, using such statements in myphp.php:
$items = Explode ("", $HTTP _post_vars["items"));
You can separate these options into arrays. Note that value in the option cannot contain a delimiter (here is a space).