I have code that hides and unhides fields based on a combo box on a web form. Here is the code
{var doc = document.forms[0];
if(doc.imprint.value == ‘Warren CAT’){document.getElementById(‘B’).style.display=‘block’;
document.getElementById(‘A’).style.display=‘none’;return false}
document.getElementById(‘A’).style.display=‘block’;
document.getElementById(‘B’).style.display=‘none’;return true;}
it works great in firefox but does not get a true statement in IE, any ideas?
Also
{var doc = document.forms[0];
if(doc.option11.value == ‘Toll’){doc.option112.value = ‘test’}
;return true;}
Works in Firefox but not IE
Subject: Javascript works in firefox but not in IE
It might help to use some proper outlining of your code to get to the error. At the moment it’s not easy to read and I think also incorrect which might be why IE breaks. You might wanto to try this:{var doc = document.forms[0];
if(doc.imprint.value == ‘Warren CAT’){
document.getElementById('B').style.display='block';
document.getElementById('A').style.display='none';
return false;
} else {
document.getElementById('A').style.display='block';
document.getElementById('B').style.display='none';
return true;
}
}
btw, using a variable “doc” to denote document.forms[0] is also bad practice. Those kind of things make your code very hard to read.
Subject: Fixed: Javascript works in firefox but not in IE
You have to make an alias in the combo box
(Warren CAT | Warren CAT)
for IE to see this value, somehow Firefox can see it without this extra code.
Thanks for the tip on the code formatting, i do not do very much java script, so i just try to get it to work the best i can.