我有一个 JavaScript 函数,它在一组复选框上执行操作,但是最终的操作是根据用户是勾选还是取消勾选设置被点击的复选框为选中或未选中状态。
不幸的是,每次检查是否被选中或未选中时,它都返回 "on",表明用户总是选中复选框!任何帮助将不胜感激,以下是 JavaScript 代码。
// Uncheck all the checkboxs with the same Tax Credit
for (i=0; i<arrChecks.length; i++)
{
var attribute = arrChecks[i].getAttribute("xid")
if (attribute == elementName)
{
// if the current state is checked, unchecked and vice-versa
if (arrChecks[i].value == "on") // <-- This is always returning true, even if the box is being unchecked
{
arrChecks[i].checked = 1;
} else {
arrChecks[i].checked = 0;
}
} else {
arrChecks[i].checked = 0;
}
}