// 全て選択押下処理
function AllChackInput(objAll){
// 全ての要素に対して
for(var i=0;i<document>
//チェックボックスであれば
if(document.AllCheck[i].type=="checkbox"){
document.AllCheck[i].checked = objAll.checked;
}
}
}
// 全て選択以外の押下処理
function AllChackOnOut(objMbr){
// チェックボックスのチェックが外れたら『全て選択』のチェックを外す
if(objMbr.checked == false){
document.AllCheck.chk99.checked = false;
return;
}
for(var i=0;i</document><document .allcheck.length;i++){>
//チェックボックスであれば
if(document.AllCheck[i].type=="checkbox"){
// 『全て選択』以外全てチェックされていたら
// 『全て選択』をチェックする
if(document.AllCheck[i].checked==false
&&
document.AllCheck[i].name!="chk99"){
return;
}
}
}
document.AllCheck.chk99.checked = true;
}
<div>
<form name="AllCheck">
<input type="checkbox" name="chk99" onclick="AllChackInput(this)" />全選択・解除<br />
<input type="checkbox" onclick="AllChackOnOut(this)" />チェック1<br />
<input type="checkbox" onclick="AllChackOnOut(this)" />チェック1<br />
<input type="checkbox" onclick="AllChackOnOut(this)" />チェック1<br />
<input type="checkbox" onclick="AllChackOnOut(this)" />チェック1
</form>
</div>