The following figure shows the pipeline instance code: formactioncheckbox. phpnbsp... we have summarized the following information about whether to select and write the check box in PHP to the database. For more information, see.
The form.html instance code is as follows:
Then create a program to process the form:
The checkbox. php instance code is as follows:
However, the above program is only used to show whether the check box is normal. If all the data in the array is retrieved one by one, a loop is required. Therefore, the program is further modified:
The checkbox. php instance code is as follows:
";}?>
The execution result is similar:
Option 3 selected
Option 15 selected
Use javascript for preprocessing. multiple check boxes with the same name exist in javascript as arrays. Therefore, before submitting a form, you can use javascript to combine the information groups in the check box into a character array and assign values to the hidden elements in the form, then, use the explode function in php to parse the array, so that the check box information can be passed. the following is an example.
Suppose there is a form:
The instance code is as follows:
This form has four check boxes whose names are item. when you click the submit button, the checker function will be called, and if the checker returns the true form, it will be submitted, if the return value is false, the form will not be submitted. here, the checker function is the preprocessing function to be compiled. add the following javascript in the html header section:
The instance code is as follows: