Uncheck all checkboxes

Uncheck all checkboxes

elshammelshamm Posts: 4Questions: 0Answers: 0
edited January 2013 in General
Hope someone can help. I currently have a check all checkboxes link on my page. Maybe I am being dense but I would like to add a link to uncheck all checkboxes, how do I go about doing this. Here is the code I have for checking all checkboxes: How would I clear all checkboxes using the second Clear All onclick event.

//Check all checkboxes
$('#form').click( function() {
$('input', oTable.fnGetNodes()).attr('checked','checked');
return false; // to avoid refreshing the page
} );

HTML form:



 
Check All


Clear All

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    [code]
    $('#form span.button:eq(1) a').click( function () {
    table.$('input').removeAttr( 'checked' );
    } );
    [/code]

    Allan
  • dlbarrondlbarron Posts: 23Questions: 1Answers: 0
    Why is it that this does not work if the checkbox in question is on a page of the DataTable that is not being displayed?
  • elshammelshamm Posts: 4Questions: 0Answers: 0
    modified it slightly, but it works. thanks!!

    $('span.button:eq(1)').bind('click', function() {
    oTable.$('input').removeAttr( 'checked' );
    return false;
    });
This discussion has been closed.