Having an odd problem with this script- it's supposed to show/hid div's based on the option selected in a selection box. It's supposed to change methodology based on common browsers. The hardest part of my needs is that I explicitly need to support IE6, IE7, IE8, FF2, and FF3. Other browsers are optional, but that IE6 throws a monkeywrench in things.
So I came up with this script, and now it supports FF2-3, but IE is catching an error, "Expected ')'" on lines (12 & 24 here).
I tried adding a '); to line 24 (you can see its difference from line 12) but it led me through several other errors, and still different work. I'm not really a javascripter, I'm PHP and Ruby- I get the general idea but I don't know enough about javascript to debug this, unfortunately.
Thanks in advance to anyone that can help me with this, it is for a project on a deadline by tommorow at 1pm; I know it's unrealistic to hope for anything, all I'm saying is that it's important to me. Or, as an alternative, if someone is familiar with another existing script that works for at least the browsers I mentioned above, that would work too.
Thanks guys! If you need more info just ask- I figured the script kind of speaks for itself (its a small addition to a very large CMS, but it's the only part having any trouble).
[Edit: Does not support IE6- I had a third party test this, and after testing myself, it appears his results were incorrect- it does not work in IE, at all, ever.]
So I came up with this script, and now it supports FF2-3, but IE is catching an error, "Expected ')'" on lines (12 & 24 here).
I tried adding a '); to line 24 (you can see its difference from line 12) but it led me through several other errors, and still different work. I'm not really a javascripter, I'm PHP and Ruby- I get the general idea but I don't know enough about javascript to debug this, unfortunately.
Code:
var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
browserType= "gecko"
}
function hide(arg) {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById("' + arg + '")');
else if (browserType == "ie")
document.poppedLayer = eval('document.getElementById("' + arg + '"');
else
document.poppedLayer =
eval('document.layers["' + arg + '"]');
document.poppedLayer.style.display = "none";
}
function show(arg) {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById("' + arg + '")');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById("' + arg + '")');
else
document.poppedLayer =
eval('document.layers["' + arg + '"]');
document.poppedLayer.style.display = "inline";
}
function update() {
if(getSelectedValue() == 0){
show("numeric_minimum");
show("numeric_maximum");
show("number_desirable");
hide("tf_desirable");
hide("multiple_answer_count");
hide("multiple_answer_captions");
hide("multiple_answer_efficiencies");
}
if(getSelectedValue() == 1){
hide("numeric_minimum");
hide("numeric_maximum");
hide("number_desirable");
show("tf_desirable");
hide("multiple_answer_count");
hide("multiple_answer_captions");
hide("multiple_answer_efficiencies");
}
if(getSelectedValue() == 2){
hide("numeric_minimum");
hide("numeric_maximum");
hide("number_desirable");
show("tf_desirable");
hide("multiple_answer_count");
hide("multiple_answer_captions");
hide("multiple_answer_efficiencies");
}
if(getSelectedValue() == 3){
hide("numeric_minimum");
hide("numeric_maximum");
hide("number_desirable");
hide("tf_desirable");
show("multiple_answer_count");
show("multiple_answer_captions");
show("multiple_answer_efficiencies");
}
if(getSelectedValue() == 4){
hide("numeric_minimum");
hide("numeric_maximum");
hide("number_desirable");
hide("tf_desirable");
show("multiple_answer_count");
show("multiple_answer_captions");
show("multiple_answer_efficiencies");
}
if(getSelectedValue() == 5){
hide("numeric_minimum");
hide("numeric_maximum");
hide("number_desirable");
hide("tf_desirable");
hide("multiple_answer_count");
hide("multiple_answer_captions");
hide("multiple_answer_efficiencies");
}
}
function getSelectedValue() {
var index = document.getElementById("selector").selectedIndex;
return index;
}
Thanks in advance to anyone that can help me with this, it is for a project on a deadline by tommorow at 1pm; I know it's unrealistic to hope for anything, all I'm saying is that it's important to me. Or, as an alternative, if someone is familiar with another existing script that works for at least the browsers I mentioned above, that would work too.
Thanks guys! If you need more info just ask- I figured the script kind of speaks for itself (its a small addition to a very large CMS, but it's the only part having any trouble).
[Edit: Does not support IE6- I had a third party test this, and after testing myself, it appears his results were incorrect- it does not work in IE, at all, ever.]
Comment