php checkbox 取值实例教程
代码1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
4 <title>无标题文档</title>
5 </head>
6
7 <body>
8 html复选框如果要以数据组形式发送给php脚本处理就必须以如checkbox[]这形式
9 <form id="form1" name="form1" method="post" action="">
10 <label>
11 <input type="checkbox" name="checkbox[]" value="1" />
12 </label>
13 <label>
14 <input type="checkbox" name="checkbox[]" value="2" />
15 </label>
16 <label>
17 <input type="checkbox" name="checkbox[]" value="www.111cn.net" />
18 </label>
19 <label>
20 <input type="checkbox" name="checkbox[]" value="111cn.net" />
21 </label>
22 <label>
23 <input type="submit" name="Submit" value="提交" />
24 </label>
25 </form>
26 </body>
27 </html>
28 <?
29 //判断是否点击提交
30 if( $_POST )
31 {
32$array = $_POST['checkbox'];
33print_r($array);
34 }
35 /*
36结果:
37Array
38(
39 => 1
40 => 2
41 => www.111cn.net
42 => 111cn.net
43)
44
45简单的很多事情在做之前觉得复杂但做起来就很容易了,像这个复选框代码就是这样了。
46 */
47 ?>
48
页:
[1]