<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$( function(){
$('#chk_all').click( function(){
if( $(this).val() == 1 )
{
$('.chk').attr("checked", "checked");
$(this).val( 0 );
}
else
{
$('.chk').removeAttr("checked");
$(this).val( 1 );
}
});
});
</script>
<input type="checkbox" name="chk_all" id="chk_all" value="1"><br><br>
<input type="checkbox" class="chk" name="chk1" id="chk1" value=""><br>
<input type="checkbox" class="chk" name="chk2" id="chk2" value=""><br>
<input type="checkbox" class="chk" name="chk3" id="chk3" value=""><br>
<input type="checkbox" class="chk" name="chk4" id="chk4" value=""><br>