我一直試圖讓下面的比較運算符工作。第二個'if'總是執行代碼中的下一個語句。我要的是能夠檢測到何時eith entryType或followupEntryType不等於字符串「長期護理保險」這裏是代碼...Javascript不是(a == b)||不(c == b)
function getComboB(sel) {
var value = sel.options[sel.selectedIndex].value;
if (value == "Rehab") {
if (!(document.getElementById('entryType').value == "Long Term Care") || !(document.getElementById('followupEntryType').value == "Long Term Care")) {
document.getElementById('followupEntryType').value = "Long Term Care";
alert("short-term rehab code");
return true;
} else {
alert("long-term rehab code");
return true;
}
}
}
你的意思是'&&'而不是'||'? – 2013-03-16 19:20:19
順便說一下,不縮進是花費太多時間試圖查看代碼無法工作的一種肯定方式。 – 2013-03-16 19:20:41
用[this]重新格式化你的代碼(http://jsbeautifier.org/) – 2013-03-16 19:21:23