Below we summarize the information about whether the check box is selected in PHP and written to the database. Friends who need to learn can refer to it.
form.html
代码如下 | 复制代码 |
Then create a program to process the form:
checkbox.php
The code is as follows | Copy code | ||||
?> |
代码如下 | 复制代码 |
$a=$_POST["s"]; |
So the program is further modified to:
checkbox.php
The code is as follows | Copy code | ||||||||||||||||
$a=$_POST["s"]; for($i=0;$i
"; } ?> The result of this execution is similar to: Option 3 is selected Option 15 selected Use javascript to do preprocessing. Multiple checkboxes with the same name still exist in the form of arrays in javascript, so before submitting the form, you can use javascript to combine the information in the checkboxes into a character array and assign it to the hidden elements in the form, and then use php in The explode function parses this array, so that the check box information can be transferred. Below are examples. Suppose there is a form like this:
This form has four checkboxes whose names are all items. When the user clicks the submit button, the checker function will be called, and if the checker returns true, the form will be submitted. If it returns false, the form will not be submitted. . The checker function here is the preprocessing function we want to write. Add the following javascript in the header section of html:
http: //www.bkjia.com/PHPjc/629008.html TechArticle Below we summarize the information about whether the check box is selected in PHP and written to the database. Friends who need to learn can refer to it. refer to. form.html code is as follows Copy code form action=checkbox.ph...
Previous article:The use and precautions of $_FILES in PHP_PHP tutorial
Next article:PHP randomly extracts some element code from an array_PHP tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|