Javascript Example
Screen shot
Javascript Select All/Unselect All checkbox

<html>
<head>
<title>Javascript Example</title>

<script language="javascript" type="text/javascript">

function checkall(objForm)
{
    len = objForm.elements.length;
    var i=0;
    for( i=0 ; i<len ; i++){
        if (objForm.elements[i].type=='checkbox')
        objForm.elements[i].checked=objForm.check_all.checked;
    }
}

</script>
</head>

<body>
<form name="frm" action="" method="post" onSubmit="return validate();">

Select All <input name="check_all" type="checkbox"   id="check_all" onClick="checkall(this.form)" value="check_all" /><br><br>

Play Football<input name="hobby1" type="checkbox" value="play_football" /><br>
Play Music<input name="hobby2" type="checkbox" value="play_music" /><br>
Listen Music<input name="hobby3" type="checkbox" value="listen_music" /><br>
Reading Newspaper<input name="hobby4" type="checkbox" value="reading_newspaper" />

<div id="msg" style="color:#FF0000"></div>

</form>
</body>
</html>

You can download source code here