To implement a select all functionality for checkboxes, first assign an id of "selectall" to your select all checkbox and give a class of "allcheck" to all other checkboxes. You can then use the following jQuery code:
$("#selectall").click(function() {
if (!$(this).is(':checked')) {
$('.allcheck').each(function(){
$(this).prop("checked", false);
});
} else {
$('.allcheck').each(function(){
$(this).prop("checked", true);
});
}
});
If a user unchecks the select all checkbox, all other checkboxes should also be unchecked. This is the expected functionality.
Please note that this answer is based on the assumption that you are using jQuery.