引用下面js
<script>
function chkall(input1,input2)
{
var objForm = document.forms[input1];
var objLen = objForm.length;
for (var iCount = 0; iCount < objLen; iCount++)
{
if (input2.checked == true)
{
if (objForm.elements[iCount].type == "checkbox")
{
objForm.elements[iCount].checked = true;
}
}
else
{
if (objForm.elements[iCount].type == "checkbox")
{
objForm.elements[iCount].checked = false;
}
}
}
}
</script>
<form id='form2'>
<table>
<tr><td><input type="checkbox" οnclick='chkall("form2",this)'/>全选</td></tr>
<tr><td><input type="checkbox" value="" /></td></tr>
<tr><td><input type="checkbox" value="" /></td></tr>
<tr><td><input type="checkbox" value="" /></td></tr>
</form>