Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选中复选框时调用函数,onclick事件不会';不要在取消勾选时点火_Javascript_Html_Internet Explorer 6_Onchange - Fatal编程技术网

Javascript 选中复选框时调用函数,onclick事件不会';不要在取消勾选时点火

Javascript 选中复选框时调用函数,onclick事件不会';不要在取消勾选时点火,javascript,html,internet-explorer-6,onchange,Javascript,Html,Internet Explorer 6,Onchange,我应该首先提到我正在使用InternetExplorer6。我正在从onChange事件调用JavaScript函数(tabModifiedHighlight)。这个函数在其他地方工作得很好。但是,当我选中复选框时,我在页面上有几个地方可以工作,但是当我取消选中复选框时,事件似乎不会触发。 下面是JavaScript函数: function tabModifiedHighlight(){ alert("alert"); var div, i, input, inputIndex,

我应该首先提到我正在使用InternetExplorer6。我正在从
onChange
事件调用JavaScript函数(
tabModifiedHighlight
)。这个函数在其他地方工作得很好。但是,当我选中复选框时,我在页面上有几个地方可以工作,但是当我取消选中复选框时,事件似乎不会触发。 下面是JavaScript函数:

function tabModifiedHighlight(){
    alert("alert");
    var div, i, input, inputIndex, selects, selectIndex, selectedTab, highlighted;
    var tabs = new Array("admissioninformation","diet","vitalsigns","activities","nursing","ivfluids","medications1","medications2","labs","respiratory","diagnostic","consultations");
    for(i=0; i<(tabs.length); i++){
        selectedTab = tabs[i]+'tab';
        if (document.getElementById(selectedTab).className == "selectedtab"){
            div = document.getElementById(tabs[i]),
            input = div.getElementsByTagName('input'),
            selects = div.getElementsByTagName('select');
            break;
        }
     }
    highlighted = false;
    for (inputIndex = 0; inputIndex < input.length; inputIndex++){
        if (input[inputIndex].checked == true){
        highlighted = true;
    }               
}
for (inputIndex = 0; inputIndex < input.length; inputIndex++){
    if (input[inputIndex].type == 'text' && input[inputIndex].value != ""){
        highlighted = true;
    }               
}
for (selectIndex = 0; selectIndex < selects.length; selectIndex++){
    if (selects[selectIndex].value != ""){
        highlighted = true;
    }               
}
if (highlighted == true){
    document.getElementById(selectedTab).style.backgroundColor = "#FF0";
}
else {
    document.getElementById(selectedTab).style.backgroundColor = "#F0F0F0";
}
函数选项卡ModifiedHighlight(){
警报(“警报”);
变量div,i,输入,输入索引,选择,选择索引,选择选项卡,高亮显示;
var选项卡=新的数组(“入院信息”、“饮食”、“生命体征”、“活动”、“护理”、“静脉输液”、“药物1”、“药物2”、“实验室”、“呼吸”、“诊断”、“咨询”);

对于(i=0;i,因为您的代码不仅适用于两个选项卡,而且适用于所有其他选项卡,这不是浏览器兼容性问题。
onClick
如果要调用这3种方法,请选中复选框
tylenoposhowhide();复选框高亮显示(此为“药物箭头2”);选项卡ModifiedHighlight()

注意
tabModifiedHighlight
是最后一个

如果前两个方法
tylenoposhowhide
checkBoxHighlight
中的任何一个失败,则不会调用
tabModifiedHighlight

我建议在
tylenoposhowhide
checkBoxHighlight
中添加警报作为第一行和最后一行


它将帮助您找到哪个函数实际上失败了,然后您可以在此处添加该代码,我们将能够进一步帮助您

非常感谢!通过按照您的建议进行调试,在其他函数的开头和结尾添加警报,我能够确定它真正启动的时间是在另一个函数的开始和结束之间在仔细检查后,我发现如果选中复选框,另一个函数调用的是tabModifiedHighlight函数。我仍然不知道为什么它没有调用onClick事件中的函数,但通过修改另一个函数来调用它(无论是否选中),我能够解析它,使它每天都工作时间到了,谢谢!
<input name="cbMedTylenolPO" id="cbMedTylenolPO" type="checkbox" value="PO" onClick="tylenolPoShowHide(); checkBoxHighlight(this, 'MedicationsRow2'); tabModifiedHighlight();" />