function yy_stv_checkParentCheckbox(table, checked)
{
/// <summary>設置父複選框的狀態</summary>
var nodes = table.parentNode.parentNode.childNodes;
for (
var i=1; i<nodes.length; i++)
{
if (nodes[i] == table.parentNode)
{
if (
typeof(nodes[i-1]) == 'undefined' ||
typeof(nodes[i-1].rows) == 'undefined')
return;
for (
var x=0; x < nodes[i-1].rows.length; x++)
{
for (
var j=0; j < nodes[i-1].rows[x].cells.length; j++)
{
// debugger;
var chk = nodes[i-1].rows[x].cells[j].childNodes[0];
if (
typeof(chk) != 'undefined' && chk.tagName ==
"INPUT" && chk.type ==
"checkbox")
{
chk.checked = checked;
yy_stv_foreachParentCheckbox(nodes[i-1]);
return;
}
}
}
}
}
}
function yy_stv_foreachChildCheckbox(obj)
{
/// <summary>單擊父複選框時,設置其子複選框的選中狀態</summary>
var checked;
if (obj.tagName ==
"INPUT" && obj.type ==
"checkbox")
{
checked = obj.checked;
do
{
obj = obj.parentNode;
}
while (obj.tagName !=
"TABLE")
}
var nodes = obj.parentNode.childNodes;
for (
var i=0; i<nodes.length - 1; i++)
{
if (nodes[i] == obj && nodes[i + 1].tagName ==
"DIV")
{
var elements = nodes[i+1].getElementsByTagName(
"INPUT");
for (j=0; j< elements.length; j++)
{
if (elements[j].type == 'checkbox')
{
elements[j].checked = checked;
}
}
}
}
}
function yy_stv_foreachParentCheckbox(obj)
{
/// <summary>單擊某一複選框時,設置其父複選框的選中狀態</summary>
var checkedNum = 0;
var uncheckedNum = 0;
if (obj.tagName ==
"INPUT" && obj.type ==
"checkbox")
{
do
{
obj = obj.parentNode;
}
while (obj.tagName !=
"TABLE")
}
var tables = obj.parentNode.getElementsByTagName(
"TABLE");
if (
typeof(tables) == 'undefined')
return;
for (
var i=0; i < tables.length; i++)
{
for (
var x=0; x < tables[i].rows.length; x++)
{
for (
var j=0; j < tables[i].rows[x].cells.length; j++)
{
var chk = tables[i].rows[x].cells[j].childNodes[0];
if (
typeof(chk) != 'undefined' && chk.tagName ==
"INPUT" && chk.type ==
"checkbox")
{
if (chk.checked)
checkedNum ++;
else
uncheckedNum ++;
}
}
}
}