CheckBox "All Select/Cancel" in the GridView perfect compatibility with IE and firefox_ practical tips

Source: Internet
Author: User
Copy Code code as follows:

function SelectAll (obj)
{
var thetable = Obj.parentNode.parentNode.parentNode.parentNode;
var i;
var j = Obj.parentNode.cellIndex;
for (i=1;i<thetable.rows.length;i++)
{
if (thetable.rows[i].cells.length<j) continue;
var objcheckbox = thetable.rows[i].cells[j].getelementsbytagname (' input ') [0];
if (objcheckbox.checked!=null) objcheckbox.checked = obj.checked;
}
}

Add onclick= "SelectAll (This)" to the Head checkbox to support any multiple-column checkbox.
Copy Code code as follows:

<asp:templatefield headertext= "<input id= ' Checkbox1 ' type= ' checkbox ' onclick= ' SelectAll (this) '/> serial number ' >
<ItemTemplate>
<input id= "Checkbox1" type= checkbox "onclick=" Get_jdzh (this); title= ' <% #Convert. ToString (Eval ("CPDM")). Trim ()%> '/>
</ItemTemplate>
</asp:TemplateField>

Thetable.rows[i].cells[j].getelementsbytagname (' input ') [0]; never use FirstChild, otherwise the FF will be wrong.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.