[code]一<input type="checkbox" name="checkbox1"><br>
二<input type="checkbox" name="checkbox1"><br>
三<input type="checkbox" name="checkbox1"><br>
四<input type="checkbox" name="checkbox1"><br>
五<input type="checkbox" name="checkbox1"><br>
<input type="checkbox" οnclick="checkAll(document.all['checkbox1'])">全选/反选
<script>
function checkAll(id)
{
if(typeof(id)=="undefined")
{
alert('没有选择的数据');return;
}
if(typeof(id.length)=="undefined")
{
id.checked=id.checked?false:true;
return;
}
for(var i=0;i<id.length;i++)
{
var checkitem=id[i];
checkitem.checked=checkitem.checked?false:true;
}
}
</script>[/code]
二<input type="checkbox" name="checkbox1"><br>
三<input type="checkbox" name="checkbox1"><br>
四<input type="checkbox" name="checkbox1"><br>
五<input type="checkbox" name="checkbox1"><br>
<input type="checkbox" οnclick="checkAll(document.all['checkbox1'])">全选/反选
<script>
function checkAll(id)
{
if(typeof(id)=="undefined")
{
alert('没有选择的数据');return;
}
if(typeof(id.length)=="undefined")
{
id.checked=id.checked?false:true;
return;
}
for(var i=0;i<id.length;i++)
{
var checkitem=id[i];
checkitem.checked=checkitem.checked?false:true;
}
}
</script>[/code]