PHP批量取得checkbox的值
上一篇 /
下一篇 2007-09-05 09:40:23
/ 个人分类:PHP
//index.php PHPChina 开源社区门户;^x[\7O(H+W
<html>
<body>
<form action="getchk.php" method="post">
<table>
<tr><td><input type="checkbox" name="chk[]" value="1"></td></tr>
<tr><td><input type="checkbox" name="chk[]" value="2"></td></tr>
<tr><td><input type="checkbox" name="chk[]" value="3"></td></tr>
</table>
<input type="submit" value="Submit">
</form>
</body>
</html>
{["xi e*gt0
//getchk.phpPHPChina 开源社区门户:Y.m0t)m(L+p
<?php
q;v a.lFO%_DJ0$p_chk=$_POST["chk"];PHPChina 开源社区门户D
s9qA%AI3L
echo "Count Checkbox : ".count($p_chk)."<br>";PHPChina 开源社区门户Nk4A?Nv
echo "Their values are : <br>";PHPChina 开源社区门户$_"D"f@A
for($i=0;$i<count($p_chk);$i++){PHPChina 开源社区门户&a5|N$u+Y{ w
echo $p_chk[$i]."<br>";
]
Bg:\&E7a0}PHPChina 开源社区门户4A$s"Gp0L
Uxy&R;i
echo "Join them with \",\" : <br>";
+zTe1l6{K0if(!is_array($p_chk)) $p_chk=array($p_chk);