Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  41] [ 5]  / answers: 1 / hits: 17560  / 11 Years ago, mon, may 13, 2013, 12:00:00

I should probably start by mentioning that I am using Internet Explorer 6. I am calling a JavaScript function (tabModifiedHighlight) from an onChange event. The function works perfectly other places however, I have a couple of places on the page where it works when I check the checkbox, but the event doesn't even seem to fire when I uncheck it.
Here is the JavaScript function:



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;
}


}



And here is the input that is calling it:



<input name=cbMedTylenolPO id=cbMedTylenolPO type=checkbox value=PO onClick=tylenolPoShowHide(); checkBoxHighlight(this, 'MedicationsRow2'); tabModifiedHighlight(); />


This page has multiple tabs which are just divs that are set to visible or hidden based on which one is selected. It seems consistent in that it works everywhere except for 2 of the tabs, and nowhere on those tabs. The only other difference I can see is that the ones that are not working are also showing or hiding divs within the tab, based on whether the checkbox is checked or not. I have added the alert at the very beginning of the function to see if it is firing or not, and it does when checking the checkbox, but not when unchecking.



I hope I made this clear, and any thoughts are appreciated!


More From » html

 Answers
63

As your code is not working only for two tabs, and working for all others its not an browser compatibility issue.

onClick if checkbox you are calling these 3 methods
tylenolPoShowHide(); checkBoxHighlight(this, 'MedicationsRow2');tabModifiedHighlight()



Note tabModifiedHighlight is last one..



if any of first two methods tylenolPoShowHide or checkBoxHighlight fails... then tabModifiedHighlight will not be called.



I will suggest to add alert as first and last line in both tylenolPoShowHide and checkBoxHighlight ...



It will help you find which one is actually failing then you can add that code here and we will be able to help you further


[#78262] Saturday, May 11, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
minab

Total Points: 701
Total Questions: 104
Total Answers: 91

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;