Javascript error in Firefox...please assist

G

gattaca8

The following script works fine in IE...but gives me a "sBox has no
properties" error in Firefox. sBox is only used in the below method.


function addTop (sectId) {
sBox = document.getElementById("addo_" + sectId);
topo = sBox.options[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}

I can't see the problem...anyone have any suggestions to try? Thanks
for your time.
 
J

Jedi Fans

The following script works fine in IE...but gives me a "sBox has no
properties" error in Firefox. sBox is only used in the below method.


function addTop (sectId) {
sBox = document.getElementById("addo_" + sectId);
topo = sBox.options[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}

I can't see the problem...anyone have any suggestions to try? Thanks
for your time.
function addTop (sectId) {
topo=document.getElementById("addo_"+sectId).options[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}
 
J

Jedi Fans

The following script works fine in IE...but gives me a "sBox has no
properties" error in Firefox. sBox is only used in the below method.


function addTop (sectId) {
sBox = document.getElementById("addo_" + sectId);
topo = sBox.options[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}

I can't see the problem...anyone have any suggestions to try? Thanks
for your time.
function addTop (sectId) {
topo=document.getElementById("addo_"+sectId).options[document.getElementById("addo_"+sectId).selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}
 
K

Kimmo Laine

The following script works fine in IE...but gives me a "sBox has no
properties" error in Firefox. sBox is only used in the below method.


function addTop (sectId) {
sBox = document.getElementById("addo_" + sectId);
topo = sBox.options[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}

I can't see the problem...anyone have any suggestions to try? Thanks
for your time.

Don't know just how many times I've suggested this, but it's always worked.
Make sure you have defined an id for the element. If it has just a name it
works in IE but it is wrong. Unless it has an id attribute it won't work in
Firefox. The error is in IE, not Firefox. But it pleases me to see that
people are more and more testing the pages with Firefox and discovering
these problems.

So if your select looks something like this...
<select name="addo_0">
<option....
</select>

It should be like
<select name="addo_0" id="addo_0">
<option....
</select>

Also, for the future, it would be useful if you presented also an example of
the form, not just the javascript code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top