<input type=checkbox name=mm value=a onclick="checkItem(this, 'mmAll')"><br>
<input type=checkbox name=mm value=b onclick="checkItem(this, 'mmAll')"><br>
<input type=checkbox name=mm value=c onclick="checkItem(this, 'mmAll')"><br>
<input type=checkbox name=mm value=d onclick="checkItem(this, 'mmAll')"><br>
<input type=checkbox name=mm value=e onclick="checkItem(this, 'mmAll')"><br><br>
<input type=checkbox name=mmAll onclick="checkAll(this, 'mm')">全选与不全选的切换
<script langage=Javascript>
fonction checkAll (e, itemName)
{
var aa = document.getElementsByName(itemName);
pour (var i=0; i<aa.length; i++)
aa[i].checked = e.checked;
}
fonction checkItem (e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
autre
{
var aa = document.getElementsByName(e.name);
pour (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = vrai;
}
}
</script>
ps : checkItem 点击事件可以去掉,以免出错)