我有一个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;
}
}
Run Code Online (Sandbox Code Playgroud) javascript ×1