首页 > 代码库 > checkbox全选、全不选实现
checkbox全选、全不选实现
<form name=aa1 >
<p>
<input type=checkbox name="radiotex" value="http://www.mamicode.com/1">1
</p> <p>
<input type=checkbox name="radiotex" value="http://www.mamicode.com/3">3
</p>
<p>
<input type=checkbox name="radiotex" value="http://www.mamicode.com/4">4
</p>
<p>
<input type=checkbox name="radiotex" value="http://www.mamicode.com/2">2
</p>
<input type = button value=http://www.mamicode.com/SelectAll onclick="SelectAll()"
</form>
<script>
checkit = true;
function SelectAll()
{
aa = document.getElementsByName("radiotex");
if (checkit)
{
for (i=0;i<aa.length;i++)
aa.item(i).checked=true;
checkit = false;
}
else
{
for (i=0;i<aa.length;i++)
aa.item(i).checked=false;
checkit = true;
}
}
</script>
checkbox全选、全不选实现