PHP receiving multiple checkboxes with the same name is not automatically converted to an array as ASP does, which brings some inconvenience to use. But there is still a solution, that is, using JavaScript to do preprocessing. More than one check box with the same name exists in JavaScript or as an array, so you can use JavaScript to synthesize a character array from a check box to a hidden element in the form before the form is submitted, and then use the Explode function in PHP to parse the array. This enables the delivery of the check box information. The following examples illustrate. Jinyun County Foreign Experts Bureau
Suppose you have a form like this:
This form has a check box with four names that are item, and when the user clicks the Submit button, the checker function is called, and if Checker returns True, the form is committed, and the return false form is not committed. Here the checker function is the preprocessing function we are going to write. Add the following JavaScript in the header section of the HTML:
This allows you to combine the value of all selected checkboxes into an array of strings, using such statements in myphp.php:
$items = Explode ("", $HTTP _post_vars["items"]);
You can separate these options into arrays. It is important to note that the value in the option cannot contain a delimiter (this is a space).
How to use Ajax to pass an array of data