javascript全选全不选代码
<script language=javascript>
function unselectall(){
if(document.myform.chkAll.checked){
documentdocument.myform.chkAll.checked = document.myform.chkAll.checked&0;
}
}
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements;
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' onclick='unselectall()' id='id' value='1'> 设计家园
<input name='id' type='checkbox' onclick='unselectall()' id='id' value='2'> 网页教程
<input name='id' type='checkbox' onclick='unselectall()' id='id' value='3'> 酷站欣赏
<input name='id' type='checkbox' onclick='unselectall()' id='id' value='4'> 网页素材
<input name='chkAll' type='checkbox' id='chkAll' onclick='CheckAll(this.form)' value='checkbox'>
全选
</form>