echo"<input type=checkbox name=box[] value=\"//值\">";
echo"<input type=checkbox name=box[] value=\"//值\">";
echo"<input type=checkbox name=box[] value=\"//值\">";
echo"<input type=checkbox name=box[] value=\"//值\">";for($i=0; $i<count($box); $i++){
echo $box[$i];
}
echo"<input type=checkbox name=box[] value=\"//值\">";
echo"<input type=checkbox name=box[] value=\"//值\">";
echo"<input type=checkbox name=box[] value=\"//值\">";for($i=0; $i<count($box); $i++){
echo $box[$i];
}
function selectAll()
{
for(var i=0; i<4; i++)
document.all.checkbox[i].checked = true
}
</script><?
for ($i=0; $i< count($checkbox)/2; $i++)
{
echo $checkbox[$i]."<br>";
}
?><form method="POST" action="<?= $PHP_SELF ?>" ></table>
<tr>
<td width="50%"><font color="#0000FF" size="2" face="Verdana"><b>yangliu</b></font></a></td>
<td width="23%"><font color="#0000FF" size="2" face="Verdana"><b><input type="checkbox" name="checkbox[]" value="yangliu"></b></font></td>
</tr>
<tr>
<td width="50%"><font color="#0000FF" size="2" face="Verdana"><b>qingcai</b></font></a></td>
<td width="23%"><font color="#0000FF" size="2" face="Verdana"><b><input type="checkbox" name="checkbox[]" value="qingcai"></b></font></td>
</tr> <tr>
<td width="50%"><font color="#0000FF" size="2" face="Verdana"><b>ethan</b></font></a></td>
<td width="23%"><font color="#0000FF" size="2" face="Verdana"><b><input type="checkbox" name="checkbox[]" value="ethan"></b></font></td>
</tr> <tr>
<td width="50%"><font color="#0000FF" size="2" face="Verdana"><b>robert</b></font></a></td>
<td width="23%"><font color="#0000FF" size="2" face="Verdana"><b><input type="checkbox" name="checkbox[]" value="robert"></b></font></td>
</tr></table>
<input type="button" value="Select All" name="B1" onClick="selectAll()">
<input type="submit" value="Submit" name="B2" >
</form>
</html>
<form method="POST" action="<?= $PHP_SELF ?>" name="checkboxform" >
然后将js中的
document.all.checkbox[i].checked = true
改为
document.all.checkboxform["checkbox[]"][i].checked = true
就不会出错了
for($i=0;$i<=25;$i++)
{$box="box".$i;
$id=$$box;
echo $id;
}
for($i=1;$i<=8;$i++)
{$r="r".$i;
echo $$r;
}
echo "$r"."$i";
echo "<br>";
}
===>
for($i=1;$i<=8;$i++){
echo ${"r$i"};
echo "<br>";
}
改为
eval("echo \$r$i;");