分享一个php处理页面中checkbox全选与全不选的代码,学习下php代码处理checkbox复选框中值的方法,有需要的朋友参考下。 php处理复选框checkbox的全选与全不选。代码: 复制代码 代码示例:<!D…,
分享一个php处理页面中checkbox全选与全不选的代码,学习下php代码处理checkbox复选框中值的方法,有需要的朋友参考下。
php处理复选框checkbox的全选与全不选。
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; " /> <title>php处理复选框checkbox的全选与全不选-www.90codes.com</title> <script language="javascript" type="text/javascript"> function check_all() { var check_list = document.getElementsByName("Bton[]"); for(var i = 0; i < check_list.length; i++) { check_list[i].checked = true; } //return false; } function check_none() { var check_list = document.getElementsByName("Bton[]"); for(var i = 0; i < check_list.length; i++) { check_list[i].checked = false; } } </script> </head> <body> <form name="form1"> <?php for($i=0;$i<10;$i++){?> <tr><td> <input type=checkbox name=Bton[]> <br> </tr></td> <?php } ?> <input type="button" name="b1" id="b1" value="全选" onclick="check_all()"/> <input type="button" name="b2" id="b2" value="全不选" onclick="check_none()"/> </from> </body> </html>
php处理获取的复选框的值。
代码:
<?php for($i=0;$i<count($_POST["Bton"]);$i++)//循环输出复选框的值 { $a=$_POST["Bton"][$i]; echo $a; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。