Arrays Quirk

Discussion in 'Javascript' started by John, Jun 21, 2005.

  1. John

    John Guest

    Hi,

    I have a script where b) works perfectly but a) carries out only
    select_onchange[0]. Any ideas on why? (everything else is the same,
    problem in FF and IE). No errors / warnings.

    John

    a)

    for(i=0; i<3; i++) {
    select_onchange(tempArray);
    }

    b)

    select_onchange(tempArray[0]);
    select_onchange(tempArray[1]);
    select_onchange(tempArray[2]);
    John, Jun 21, 2005
    #1
    1. Advertising

  2. John

    John Guest

    Duncan Booth wrote:

    > John wrote:
    >
    >
    >>I have a script where b) works perfectly but a) carries out only
    >>select_onchange[0]. Any ideas on why? (everything else is the same,
    >>problem in FF and IE). No errors / warnings.
    >>
    >>a)
    >>
    >> for(i=0; i<3; i++) {
    >> select_onchange(tempArray);
    >> }
    >>
    >>b)
    >>
    >> select_onchange(tempArray[0]);
    >> select_onchange(tempArray[1]);
    >> select_onchange(tempArray[2]);

    >
    >
    > 'i' is a global variable, so perhaps something in your select_onchange
    > function is also using the same global variable 'i' which could cause the
    > loop to terminate prematurely?
    >
    > I suggest you make sure that your for loop is inside a function and declare
    > 'i' as a local variable.


    Fixed. Thank you very much. I naively assumed that it would work like
    java. I was nowhere near fixing it until you told me that.

    John
    John, Jun 21, 2005
    #2
    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. Chris Morris

    Re: dtd and quirk mode

    Chris Morris, Jul 22, 2003, in forum: HTML
    Replies:
    0
    Views:
    384
    Chris Morris
    Jul 22, 2003
  2. Richard
    Replies:
    1
    Views:
    400
  3. Blinky the Shark

    Konqueror Quirk? Safari?

    Blinky the Shark, Feb 18, 2004, in forum: HTML
    Replies:
    9
    Views:
    431
    Blinky the Shark
    Feb 20, 2004
  4. Spartanicus

    IE6 quirk check

    Spartanicus, Jul 16, 2004, in forum: HTML
    Replies:
    2
    Views:
    436
    Spartanicus
    Jul 16, 2004
  5. Philipp
    Replies:
    21
    Views:
    1,101
    Philipp
    Jan 20, 2009
Loading...

Share This Page