<script>
function chkall()
{
\t var checkbox = document.getElementById('checkbox');
\t var checkbox2 = document.getElementById('checkbox2');
\t if(checkbox.checked==true)
\t {
\t \t checkbox2.checked=true; \t
\t }
}
</script>
<table width="10%" border="0">
<tr>
<th scope="col"><input type="checkbox" onclick="chkall()" name="checkbox" id="checkbox" /></th>
</tr>
<?php
$i=0;
while($i<5)
{
?>
<tr>
<th scope="col"><input type="checkbox" name="checkbox2" id="checkbox2" /></th>
</tr>
<?php
$i++;
}
?>
</table>
我里面复选框,而这是运行循环5次。我有一个循环上方的复选框。当我点击上面的复选框时,我想检查循环内的所有复选框。
欢迎来到Stack Overflow!请看[ask]和[mcve] – Tushar