<form id="form1" name="form1" method="get" action="cc.php">
改成
<form id="form1" name="form1" method="POST" action="cc.php">要不就$aa = $_GET['checkbox'];
改成
<form id="form1" name="form1" method="POST" action="cc.php">要不就$aa = $_GET['checkbox'];
aa = Request.Form("Checkbox") Response.Write(aa)
%>打印结果 :0, 1, 2, 3, 4, 5, 6, 8, 7
$aa = $_POST['checkbox'];for($i=0;$i<count($aa);$i++){
echo $aa[$i];
}
?>这样运行就正常了`~~~谢谢!!!
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> <label>
<input type="checkbox" name="checkbox[]" id="checkbox" value="0" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="1" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="2" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="3" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="4" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="5" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="6" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="8" />
<input name="checkbox" type="checkbox[]" id="checkbox" value="7" />
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> <label>
<input type="submit" name="Submit" value="提交" />
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
<?php
$aa = $_POST['checkbox'];
echo $aa;
?> 成数组后输出来
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> <label>
<input type="checkbox" name="checkbox[]" id="checkbox" value="0" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="1" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="2" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="3" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="4" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="5" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="6" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="8" />
<input name="checkbox[]" type="checkbox" id="checkbox" value="7" />
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> <label>
<input type="submit" name="Submit" value="提交" />
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form> <?php
$aa = $_POST['checkbox'];
for($i=0;$i <count($aa);$i++)
{
echo $aa[$i]."<br>";
}
?> 这样就没有问题了的。
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> <label>
<?PHP for($i=0;$i<=8;$i++){?>
<input name="checkbox<?PHP echo $i;?>" type="checkbox" value="<?PHP echo $i;?>" " />
<?PHP }?>
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> <label>
<input type="submit" name="Submit" value="提交" />
</label> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
cc.php
<?php
for($i=0;$i<=8;$i++){
echo $_POST['checkbox.$i']."<br>";
}
?>
要使你的 <form> 结果被当成 array 发送到 PHP 脚本,要对 <input>,<select> 或者 <textarea> 单元这样命名: <input name="MyArray[]" />
<input name="MyArray[]" />
<input name="MyArray[]" />
<input name="MyArray[]" />
注意变量名后的方括号,这使其成为一个数组。可以通过给不同的单元分配相同的名字来把单元分组到不同的数组里: <input name="MyArray[]" />
<input name="MyArray[]" />
<input name="MyOtherArray[]" />
<input name="MyOtherArray[]" />
这将产生两个数组,MyArray 和 MyOtherArray,并发送给 PHP 脚本。还可以给数组分配指定的键名: <input name="AnotherArray[]" />
<input name="AnotherArray[]" />
<input name="AnotherArray[email]" />
<input name="AnotherArray[phone]" />
AnotherArray 数组将包含键名 0,1,email 和 phone。
注意: 指定数组的键名是 HTML 的可选项。如果不指定键名,则数组被按照单元在表单中出现的顺序填充。第一个例子将包含键名 0,1,2 和 3。