Help !!! Object doesn't support this property or method !!!!

G

Gianni

In my javascript script I get this error which is a simple warning
with my IE but in other OS throws a nasty error. here is my code !
Consider that valore2 and valore16 are not empty and the program go on
correctly.

var valore2
var valore16

function trova_period_g() {


valore2 = document.form.s2g.options[document.form.s2g.selectedIndex].value
valore16 = document.form.s2g.options[document.form.s2g.selectedIndex].name

}

and of course I have a select like this

<p><center><b>Periodicità</b>
<p><center><b>&nbsp;</b></p>
<select name="s2g" onChange="period()" size=11>
<option value="001440"name = "Giornaliera">Giornaliera</option>
</select>
 
M

Michael Winter

In my javascript script I get this error which is a simple warning with
my IE

A warning? I doubt that. If the script contains an error, it's an error.
The only warnings I've seen IE display are security warnings.
but in other OS throws a nasty error.

As they should.
here is my code !
Consider that valore2 and valore16 are not empty and the program go on
correctly.

var valore2
var valore16

function trova_period_g() {


valore2 =
document.form.s2g.options[document.form.s2g.selectedIndex].value
valore16 =
document.form.s2g.options[document.form.s2g.selectedIndex].name

The problem is that there is no form (well, you certainly haven't shown
one). The exact solution will depend on how this function is called.
You'll have to show more code (a URL would be best).

Before I finish, I'd like to suggest that you learn to save references to
frequently used objects. Not only will it result in quicker execution, but
it makes your script smaller, too. The two lines above could be reduced to
(I'm assuming there is a form called 'form'):

var s2g = document.forms['form'].elements['s2g'];
valore2 = s2g.options[s2g.selectedIndex].value;
valore16 = s2g.options[s2g.selectedIndex].name;

If you were so inclined, you could also save the value of selectedIndex.
}

and of course I have a select like this

<p><center><b>Periodicità</b>
<p><center><b>&nbsp;</b></p>

The HTML is above is invalid. CENTER elements must have closing tags.
However, you shouldn't be using them anyway: they're deprecated in favour
of a CSS solution.
<select name="s2g" onChange="period()" size=11>
<option value="001440"name = "Giornaliera">Giornaliera</option>

Be careful with your whitespace. I think browsers will correctly parse the
attributes above, but do try to make sure that you add spaces properly
just in case some browsers do reject it.
</select>

Mike
 
S

Shawn Milo

In my javascript script I get this error which is a simple warning
with my IE but in other OS throws a nasty error. here is my code !
Consider that valore2 and valore16 are not empty and the program go on
correctly.

var valore2
var valore16

function trova_period_g() {


valore2 = document.form.s2g.options[document.form.s2g.selectedIndex].value
valore16 = document.form.s2g.options[document.form.s2g.selectedIndex].name

}

and of course I have a select like this

<p><center><b>Periodicità</b>
<p><center><b>&nbsp;</b></p>
<select name="s2g" onChange="period()" size=11>
<option value="001440"name = "Giornaliera">Giornaliera</option>
</select>

Try getting rid of the name="Giornaliera" part and
replace

valore16 = document.form.s2g.options[document.form.s2g.selectedIndex].name
with
valore16 = document.form.s2g.options[document.form.s2g.selectedIndex].text


Shawn
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top