<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
function getForm( elem ) {
if ( elem.form ) return elem.form;
var form = elem.parentNode;
while ( form && form.nodeName.toLowerCase() != 'form' ) {
form = form.parentNode;
}
return (elem.form = form);
}
function checkAll( oForm, reName, checked ){
if ( !oForm ) return;
var inputList = oForm.getElementsByTagName("input");
for ( var i = 0, elem; (elem = inputList[i++] ); ) {
if ( elem.type == 'checkbox' && reName.test( elem.name) ) {
elem.checked = checked;
}
}
}
</script>
</head>
<body>
<form action="">
<ul>
<li><input type="checkbox" name="total" onclick="checkAll( this.form || getForm(this), /checkbox\[\d+\]/, this.checked )"> Check(Uncheck) All</li>
<li><input type="checkbox" name="checkbox[0]"/> 1</li>
<li><input type="checkbox" name="checkbox[1]"/> 2</li>
<li><input type="checkbox" name="checkbox[2]"/> 3</li>
<li><input type="checkbox" name="checkbox[3]"/> 4</li>
<li><input type="checkbox" name="checkbox[4]"/> 5</li>
</ul>
</form>
</body>
</html>