我如何遍历JavaScript中的gridview并检查复选框是否已选中 [英] How can I iterate through a gridview in javascript and check if the checkbox is checked or not
本文介绍了我如何遍历JavaScript中的gridview并检查复选框是否已选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function ComparePopup(gridName, value) {
var myGrid = document.getElementById("<%= gridviewSearchResult.ClientID %>");
var oRows = myGrid.rows;
var rawDataRows = new Array();
var hdncounter = document.getElementById("<%= hdnCounter.ClientID %>");
var hdncount = document.getElementById("<%= hidCounter.ClientID %>");
var cell;
var j;
for (var i = 0; i < oRows.length; i++) {
var oRow = oRows[i];
// for (var j = 0; j < oRows.cells.length; j++) {
alert(myGrid.rows(i).cells(0).textContent);
// if (oRow.getCell(0).getValue() == "true") {
// j = j + 1;
// }
// }
}
if (hdncounter != "") {
var counter = parseInt(hdncounter.value);
hdncount.value = j + counter;
}
else {
hdncount.value = j;
}
if (hdncount.value > 3) {
var res = confirm("Since you have selected more than 3 profiles, their profiles will be exported to excel for comparison.");
if (res != true)
return false;
else
return true;
}
}
推荐答案
function ComparePopup(gridName, value) {
var myGrid = document.getElementById("<%= gridviewSearchResult.ClientID %>");
var oRows = myGrid.rows;
var rawDataRows = new Array();
var inps = myGrid.getElementsByTagName("input");
var hdncounter = document.getElementById("<%= hdnCounter.ClientID %>");
var hdncount = document.getElementById("<%= hidCounter.ClientID %>");
var cell;
var j=0;
for (var i = 0; i < oRows.length; i++) {
var oRow = oRows[i];
if (myGrid.rows(i).cells(0).children[0] != null && myGrid.rows(i).cells(0).children[0].checked == true) {
j = j + 1;
}
}
if (hdncounter != "") {
var counter = parseInt(hdncounter.value);
hdncount.value = j + counter;
}
else {
hdncount.value = j;
}
if (hdncount.value > 3) {
var res = confirm("Since you have selected more than 3 profiles, their profiles will be exported to excel for comparison.");
if (res != true)
return false;
else
return true;
}
}
这篇关于我如何遍历JavaScript中的gridview并检查复选框是否已选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文