JavaScript Implementation of GriwView single-column full selection (self-writing code) _ javascript skills

Source: Internet
Author: User
In the GridView, there are a series of checkboxes. to select all or all of them, there are no such items and requirements on the Internet, so I wrote the JavaScript code myself, post it for your reference. There are a series of checkboxes in the GridView. You need to select all or none of them. I found it online, but the reference code Selects all the checkboxes in the GridView, and I want all of them in a single column.

Audit and permissions must be separated.


I wrote JavaScript code and posted it for your reference.

The Code is as follows:


Function chkAll (CheckAll ){
Var items = document. getElementsByTagName ("input ");
For (var I = 0; I <items. length; I ++ ){
If (items [I]. type = "checkbox "){
For (var j = 2; j <10; j ++ ){
Var id = "ctl00_ContentPlaceHolder1_GridView1_ctl0" + j + "_ CheckBox1 ";
If (items [I]. id = id ){
Items [I]. checked = CheckAll. checked;
}
}
}
}
}


The IDS of Row j and row 5th of row 6th are used to determine the Checkbox of the same column. The range and id of the specific column j may be different. You can use alert (items [I]. id); traverse the entire items to view the corresponding id.
The front-end code is as follows:

The Code is as follows:





Review


'Runat = "server"/>


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.