Wednesday, August 18, 2010

Code for Select and deselect all check boxes in javascript.?

I have to select and deselect a check box column in a datagrid. When i click the header check box all the checkboxes in the column should be checked and vice-versa for uncheck also. But if we uncheck a single check box after checking all checkboxes , the header check box should also be unchecked. Sorry for confusing like this. Because my English is Somewhat bad. Anybody pls send me sample code for this and how to call the javascript function in HTML.Code for Select and deselect all check boxes in javascript.?
you can try to write a javascript function like this:(only a sketch)


Supose that your form name is my form


function checkall(r) {


for (i = 1; i %26lt; myform.elements.length; i++) {


if (document.myform.elements[i]) {


if(document.myform.elements[i].type %26amp;%26amp; document.files.elements[i].type!='checkb鈥?continue;


document.myform.elements[i].checked = 1;


}


}


}


if you want to download a ready-made script for doing this you can go there::)


http://www.shawnolson.net/a/639/select-a鈥?/a>

No comments:

Post a Comment