Select all and deselect all checkboxes with jQuery
This is how you can select all and deselect all checkboxes with jQuery
<div><a href='#' id='select-all'>Select all</a> - <a href='#' id='deselect-all'>Deselect all</a></div>
$('#select-all').click(function(){
$('#zimonitor-reporting-template-objects-form input').attr('checked', 'checked');
});
$('#deselect-all').click(function(){
$('#zimonitor-reporting-template-objects-form input').removeAttr('checked');
});Same but a bit Drupal related...
...
"<div><a href='#' id='select-all'>Select all</a> - <a href='#' id='deselect-all'>Deselect all</a></div>"
...
$script = "$('#select-all').click(function(){
$('#zimonitor-reporting-template-objects-form input').attr('checked', 'checked');
});
$('#deselect-all').click(function(){
$('#zimonitor-reporting-template-objects-form input').removeAttr('checked');
});";
drupal_add_js($script, 'inline', 'footer');