Feb10

The “select all” checkbox to select all checkboxes

Posted by: Brian Chan | Filed in: technology | Tags: | 05:07 pm, February 10th, 2012 Add comments

Below is what you need for a “select all” checkbox to toggle the rest of the checkboxes. Below assumes your checkboxes all have the name “my_chkboxes[]“.

1
2
3
4
5
6
7
8
9
$('#my_select_all').click(function(){
	$("input[name='my_chkboxes[]']").each(function (index, el) {
		if ($('#my_select_all').is(':checked')) {
			$(el).attr('checked', 'checked');
		}else{
			$(el).attr('checked', false);
		}
	});	
});



Related posts:

  1. Disallow de-select when select-all is checked
  2. selecting checkboxes
  3. Select the last option of a drop down
  4. PHP array delete an item
  5. CLLocationManager error

Leave a Reply