<script language=javascript>
function unselectall(){
if(document.myform.chkAll.checked){
document.myform.chkAll.checked = document.myform.chkAll.checked&0;
}
}
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.Name != 'chkAll'&&e.disabled==false)
e.checked = form.chkAll.checked;
}
}
</script>
在网页中html中的代码:
<form name="myform" method="post" id="myform" action="" >
<input name='id' type='checkbox' οnclick='unselectall()' id='id' value='1'> 设计家园
<input name='id' type='checkbox' οnclick='unselectall()' id='id' value='2'> 网页教程
<input name='id' type='checkbox' οnclick='unselectall()' id='id' value='3'> 酷站欣赏
<input name='id' type='checkbox' οnclick='unselectall()' id='id' value='4'> 网页素材
<input name='chkAll' type='checkbox' id='chkAll' οnclick='CheckAll(this.form)' value='checkbox'>
全选
</form>