<input type=checkbox name=mm value=a onclick="Item(this, 'mmAll')"/><br/>
<input type=checkbox name=mm value=b onclick="Item(this, 'mmAll')"/><br/>
<input type=checkbox name=mm value=c onclick="Item(this, 'mmAll')"/><br/>
<input type=checkbox name=mm value=d onclick="Item(this, 'mmAll')"/><br/>
<input type=checkbox name=mm value=e onclick="Item(this, 'mmAll')"/><br/><br/>
<input type=checkbox name=mmAll onclick="All(this, 'mm')">全选与不全选的切换
<script language=Javascript>
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked; //得到那个总控的复选框的选中状态
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
307

被折叠的 条评论
为什么被折叠?



