423,850 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

Javascript error in Firefox...please assist

P: n/a
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.

Aug 1 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ga******@gmail.com wrote:
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).optio ns[sBox.selectedIndex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}
Aug 1 '05 #2

P: n/a
ga******@gmail.com wrote:
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).optio ns[document.getElementById("addo_"+sectId).selectedIn dex].value;
if (topo != '0'){
drawTop(sectId, topo);
} else {
alert('Please select a topic.');
}
}
Aug 1 '05 #3

P: n/a
<ga******@gmail.com> kirjoitti
viestissä:11**********************@f14g2000cwb.goo glegroups.com...
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.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>

Soulman <et****************@5P4Mgmail.com>
Aug 1 '05 #4

P: n/a
wrote:
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'm assuming Kimmo Laine already gave you the correct answer, but another
minor point is that you probably wanted sBox and topo to be local
variables (i.e. declare them using the 'var' keyword): using global
variables as you do here is a likely way to introduce obscure bugs.
Aug 1 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.