【发布时间】:2012-05-13 23:22:14
【问题描述】:
我在下面有一个 javascript 函数 - 事实上,我在转发器中有一个复选框,在其中有一个 gridview,其中又有一些复选框。
我想根据中继器复选框的选择启用禁用 gridviewCheckboxes。
所以我在 itemsRepeater_ItemDataBound 上注册了一个 javacript。捕获 - 中继器的哪个复选框 -> (RepeaterCheckBoxId) 和哪个 GridView(Grid) 如下。
函数 EnableDisable(RepeaterCheckboxid, Grid) {
var grid = document.getElementById(Grid);
if (grid == null)
return;
//variable to contain the cell of the grid
var cell;
if (grid.rows.length > 0) {
//loop starts from 1. rows[0] points to the header.
for (i = 1; i < grid.rows.length; i++) {
//get the reference of first column
cell = grid.rows[i].cells[1];
cell.childNodes[0].checked = document.getElementById(RepeaterCheckboxid).checked;//If repeater checkbox is Unchecked then gridview checkboxes should be unchecked.* This is not working.
cell.childNodes[0].disabled = !document.getElementById(RepeaterCheckboxid).checked; //If repeater checkbox is checked then gridViewCheckboxes are enabled and vice versa.This is working.
}
}
}
但我观察到启用禁用工作正常但未选中检查不起作用。 如果未选中中继器的复选框,如何取消选中gridview中的所有复选框?
如果大家有什么想法,请帮帮我。
【问题讨论】:
标签: javascript jquery asp.net