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

Discussion in 'Javascript' started by Gianni, Sep 9, 2004.

  1. Gianni

    Gianni Guest

    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>
    Gianni, Sep 9, 2004
    #1
    1. Advertising

  2. On 8 Sep 2004 23:43:32 -0700, Gianni <> wrote:

    > 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

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Sep 9, 2004
    #2
    1. Advertising

  3. Gianni

    Shawn Milo Guest

    (Gianni) wrote in message news:<>...
    > 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
    Shawn Milo, Sep 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. todd
    Replies:
    3
    Views:
    5,787
  2. Roman
    Replies:
    0
    Views:
    4,018
    Roman
    Jan 4, 2004
  3. zdrakec
    Replies:
    0
    Views:
    547
    zdrakec
    Sep 26, 2007
  4. Joe
    Replies:
    3
    Views:
    544
  5. JohnE
    Replies:
    1
    Views:
    1,030
    JohnE
    Mar 9, 2010
Loading...

Share This Page