Wednesday, December 12, 2007

checkbox すべてをON・OFF PHPの場合

function checkAll() {
if(document.myForm.checkall.checked){
for(i=0;i if (document.myForm.elements[i].name == "ch[]"){
document.myForm.elements[i].checked = true;
}
}
}else{
for(i=0;i if (document.myForm.elements[i].name == "ch[]"){
document.myForm.elements[i].checked = false;
}
}
}
}

-----

<input type="checkbox" name="checkall" value="" onclick="checkAll(); ">
<input type="checkbox" name="ch[]" value="1">
<input type="checkbox" name="ch[]" value="2">

No comments: