Hola:
Le he hecho una pequeña modificación, te dejo el ejemplo completo.
Código:
<?xml version="1.0" encoding="windows-1252"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<form name="form1" action="" method="post">
<input name="borrar[1]" id="borrar[]" type="checkbox">
<input name="borrar[2]" id="borrar[]" type="checkbox">
<input name="borrar[3]" id="borrar[]" type="checkbox">
<input type="button" value="Check" onclick="checkall();"/>
</form>
</body>
<script>
function checkall() {
i=0;
var arraycheck = document.form1["borrar[]"];
totalcontroles=arraycheck.length;
if (totalcontroles > 0)
//if (arraycheck[0].checked==true)
while (i<totalcontroles){
if (arraycheck[i].disabled == false)
arraycheck[i].checked=true;
else
arraycheck[i].checked=false;
i=i+1;
}
else
while (i<totalcontroles){
arraycheck[i].checked=false;
i=i+1;
}
}
</script>
</html>
Hasta Luego .-