Asp.net blogs

Friday 5 July 2013

Checked All checkbox during Grid View Load while Page Load using Javascript Code

Checked All checkbox during Grid View Load while Page Load using Javascript Code with the following code :

<HeaderTemplate>
<input id="chkAll" onclick="javascript:SelectAllChkboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
   <script type="text/javascript">

function SelectAllChkboxes(spanChks) {

var oItem = spanChks.children;
var theBox = (spanChks.type == "checkbox") ? spanChks : spanChks.children.item[0];
xState = theBox.checked;
elme = theBox.form.elements;
for (i = 0; i < elme.length; i++)
if (elme[i].type == "checkbox" && elme[i].id != theBox.id) {
if (elme[i].checked != xState)
elme[i].click();
}

}
</script>

No comments:

Post a Comment