Somashekhar
Somashekhar

Reputation: 513

How to check/uncheck all HTML checkboxs inside the ListView using javascript

I have a ListView, inside the ListView I placed html checkboxes(datarow and header), if I click header checkbox, it has to check all datarow checkboxes

Upvotes: 0

Views: 929

Answers (1)

Christophe
Christophe

Reputation: 28134

Here is a jQuery sample:

$("#HeaderCheckbox").click(function() {
// get the state of the header checkbox (checked or unchecked)
var state = this.checked;
   // apply it to the other checkboxes
   $("input:checkbox").each(function() {
   this.checked = state;
   });
});

With plain JavaScript the technique is the same: get the state of the header checkbox and apply it to the others.

Upvotes: 3

Related Questions