我有一个 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;
}
}