<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>复选框全选,不选和反选的效果(2)</TITLE>
<SCRIPT language=javascript>
function CheckOthers(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
// if (e.name != 'chkall')
if (e.checked==false)
{
e.checked = true;// form.chkall.checked;
}
else
{
e.checked = false;
}
}
}
function uncheckAll() {
for (var i = 0; i <form.elements.length; i++) {
var e = form.elements[i];
if (e.checked == true) e.checked = false;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
// if (e.name != 'chkall')
e.checked = true// form.chkall.checked;
}
}
</script>
</HEAD>
<BODY>
<FORM name=form action="">
<INPUT type="checkbox" value="123" name="checked">
<INPUT type="checkbox" value="234" name="checked">
<INPUT type="checkbox" value="345" name="checked">
<INPUT type="checkbox" value="456" name="checked">
<BR>
<INPUT title="选择所有" style="FONT-SIZE: 9pt" onclick="CheckAll(this.form)" type="button" value="全 选" name="chkall">
<INPUT title="反向选择" style="FONT-SIZE: 9pt" onclick="CheckOthers(this.form)" type="button" value="反 选" name="chkOthers">
<INPUT title="反向选择" style="FONT-SIZE: 9pt" onclick="uncheckAll(this.form)" type="button" value="不 选" name="unchkAll">
</FORM>
</BODY>
</HTML>