JavaScript

체크박스 전체 선택 및 전체 선택 해제 (4)
  • 조회수 490
  • 작성일 2018-07-10
  •  
var checkflag = "false";
function allC() {
// 전체선택을 했을 경우
if (checkflag == "false") {
document.fregister.policy.checked = true;
document.fregister.provision.checked = true;
checkflag = "true";
}
// 전체해제를 했을 경우
else {
document.fregister.policy.checked = false;
document.fregister.provision.checked = false;
checkflag = "false";
}
}
<input type="checkbox" id="consent_check" name="consent_check" onclick="allC();" style="margin-top:-2px"/>
<form  name="fregister" id="fregister" action="/common/register_form.php" method="POST" autocomplete="off">
<input type="checkbox" id="provision" name="provision" value="1" style="margin-top:-2px"/>
<input type="checkbox" id="policy" name="policy" value="1" style="margin-top:-2px"/>
</form>