Using multiple checks in gridview with Javascript.-VBForums
Results 1 to 1 of 1

Thread: Using multiple checks in gridview with Javascript.

Hybrid View

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006

    Using multiple checks in gridview with Javascript.

    Ok since i see this question asked a lot of times i will put it here for future reference.
    So how would you create a column of checkboxes that will be checked and unchecked accordingly and also check all the checkboxes with one click.

    Use something like this on the gridview:
      <Columns> .......etc
                             <input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);"  runat="server" type="checkbox" />
                             <asp:CheckBox ID="ChkboxUn" runat="Server" />
    .....etc   </Columns>
    Then on the js function write:
    function SelectAllCheckboxes(spanChk) {
            var oItem = spanChk.children;
            var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];
            xState = theBox.checked;
            elm = theBox.form.elements;
            for (i = 0; i < elm.length; i++)
                if (elm[i].type == "checkbox" && elm[i].id != {
                if (elm[i].checked != xState)
    Last edited by sapator; Aug 31st, 2011 at 08:11 PM.
    Slow as hell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width