<script>
   function box()
{
var list="";
  for (var i=0;i<document.kkkk.elements.length;i++)  
      {
var e = document.kkkk.elements[i];    
 if (e.checked&&e.name=="MailID")
   list=e.value+"|"+list;
 }
 return list;
}function mee()
{
if(box())
{
document.kkkk.boxs=box();
return true;
}
return false;
}
</script>
<from action="re.php" method="post"  name="kkkk" onSubmit=return mee()>
<input type="checkbox" name="sel">
<input type="checkbox" name="sel">
<input type="checkbox" name="sel">
<input type="checkbox" name="sel">
<input type="checkbox" name="sel">
<input type="checkbox" name="sel">
<input type="hidden" name="boxs" value="0">
</from>re.php.........
$boxs=explode("|",$_POST['boxs']);
for($i=0;$i<count($boxs)-1;$i++)
echo $boxs[$i]."<br>";

解决方案 »

  1.   

    <from action="re.php" method="post">
    <input type="checkbox" name="sel[]">
    <input type="checkbox" name="sel[]">
    <input type="checkbox" name="sel[]">
    <input type="checkbox" name="sel[]">
    <input type="checkbox" name="sel[]">
    <input type="checkbox" name="sel[]">
    </from>
      

  2.   

    这个问题在php手册的第一部分说的很清楚了。php在处理表单元素是并不将同名元素自动作为数组,而需要程序员在表单中显式的声明。凡是你期望携带多个数据的表单元素在命名时要以数组的形式。
    比如:checkbox -> checkboxname[]
    可复选的select -> selectname[]