check uncheck all check box using javascript and jquery

function selectallCHBox(){ if($(‘#selectall’).attr(‘checked’)){var inputs = document.getElementsByClassName(‘chechid’);var checkboxes = [];for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') {inputs[i].checked =true; } } }else { var inputs = document.getElementsByClassName('chechid');var checkboxes = [];for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') {inputs[i].checked =false; } }}}
Your ckname are
name 1
name 2
name 3
name 4
name 5
name 6

Select / Unselect All

function selectallCHBox(){

if($(‘#selectall’).attr(‘checked’)){
var inputs = document.getElementsByClassName(‘chechid’);
var checkboxes = [];
for (var i = 0; i < inputs.length; i++) {

  if (inputs[i].type == ‘checkbox’) {
inputs[i].checked =true; } }
}
else {
var inputs = document.getElementsByClassName(‘chechid’);
var checkboxes = [];
for (var i = 0; i < inputs.length; i++) {

  if (inputs[i].type == ‘checkbox’) {
inputs[i].checked =false; } }

}

}

Your ckname are

name 1

name 2

name 3

name 4

name 5

name 6

Select / Unselect All

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s