Home > Web Front-end > JS Tutorial > body text

JavaScript implements GriwView single column selection (self-written code)_javascript skills

WBOY
Release: 2016-05-16 17:33:51
Original
1354 people have browsed it

There are a series of Checkboxes in the GridView, which need to be selected or unselected. I started looking for it online, but the reference code will select all Checkboxes in the GridView, and what I want is to select all in a single column. As shown in the picture:
JavaScript implements GriwView single column selection (self-written code)_javascript skills
Audit and permissions must be separated.
JavaScript implements GriwView single column selection (self-written code)_javascript skills
JavaScript implements GriwView single column selection (self-written code)_javascript skills
I wrote the JavaScript code myself and posted it for your reference.

Copy code 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;
}
}
}
}
}

Among them, j in line 5 and j in line 6 id is used to determine the Checkbox of the same column. The specific range of j and id may be different. You can use alert(items[i].id); to traverse the entire items to view the corresponding id.
The corresponding code for the front desk is as follows:
Copy code The code is as follows:




Audit






Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template