<input type="checkbox" name="AAA" onclick="All(this, 'province')">全选1<br>
<input type='checkbox' name='province' value='110000' onclick="Item(this, 'AAA')">北京市<br>
<input type='checkbox' name='province' value='120000' onclick="Item(this, 'AAA')">天津市<br>
<input type='checkbox' name='province' value='130000' onclick="Item(this, 'AAA')">河北省<br>
<input type='checkbox' name='province' value='140000' onclick="Item(this, 'AAA')">山西省<br>
......<input type="checkbox" name="BBB" onclick="All(this, 'study')">全选2<br>
<input type='checkbox' name='study' value='1' onclick="Item(this, 'BBB')">小学生<br>
<input type='checkbox' name='study' value='2' onclick="Item(this, 'BBB')">中学生<br>
<input type='checkbox' name='study' value='3' onclick="Item(this, 'BBB')">大学专科<br>
<input type='checkbox' name='study' value='4' onclick="Item(this, 'BBB')">大学本科<br>
<input type='checkbox' name='study' value='5' onclick="Item(this, 'BBB')">研究生<br>
<input type='checkbox' name='study' value='6' onclick="Item(this, 'BBB')">博士<br><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>
<input type='checkbox' name='province' value='110000' onclick="Item(this, 'AAA')">北京市<br>
<input type='checkbox' name='province' value='120000' onclick="Item(this, 'AAA')">天津市<br>
<input type='checkbox' name='province' value='130000' onclick="Item(this, 'AAA')">河北省<br>
<input type='checkbox' name='province' value='140000' onclick="Item(this, 'AAA')">山西省<br>
......<input type="checkbox" name="BBB" onclick="All(this, 'study')">全选2<br>
<input type='checkbox' name='study' value='1' onclick="Item(this, 'BBB')">小学生<br>
<input type='checkbox' name='study' value='2' onclick="Item(this, 'BBB')">中学生<br>
<input type='checkbox' name='study' value='3' onclick="Item(this, 'BBB')">大学专科<br>
<input type='checkbox' name='study' value='4' onclick="Item(this, 'BBB')">大学本科<br>
<input type='checkbox' name='study' value='5' onclick="Item(this, 'BBB')">研究生<br>
<input type='checkbox' name='study' value='6' onclick="Item(this, 'BBB')">博士<br><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>
<body>
<script>
function checkAll(name)
{
var myObj = window.event.srcElement;
var myWork = document.getElementsByTagName('input');
for(var i=0;i<myWork.length;i++)
{
if(myWork[i].name==name+"[]")
{
myWork[i].checked = myObj.checked;
}
}
}</script>
<input type=checkbox name='work[]' value=1>11111 <br>
<input type=checkbox name='work[]' value=2>222 <br>
<input type=checkbox name='work[]' value=3>333 <br>
<input type=checkbox name='work[]' value=4>444 <br>
<input type=checkbox name='work[]' value=5>555 <br>
<input type=checkbox name='work[]' value=6>666 <br>
<hr>
<input type=checkbox name='' onclick="checkAll('work')">work <br>
<br><br>
<input type=checkbox name='study[]' value=7>777 <br>
<input type=checkbox name='study[]' value=8>888 <br>
<input type=checkbox name='study[]' value=9>999 <br>
<input type=checkbox name='study[]' value=10>1010101 <br>
<input type=checkbox name='study[]' value=11>11111111 <br>
<input type=checkbox name='study[]' value=12>121212 <br>
<hr>
<input type=checkbox name='' onclick="checkAll('study')">study <br>
</body>
</html>