Function seems to exit early

Discussion in 'Javascript' started by Rob, Mar 16, 2007.

  1. Rob

    Rob Guest

    Hi all,

    Can anyone help me understand why the checkMajor() function (at the
    very bottom of this script) is not being executed after the if/else
    statement? The function just seems to die after successfully executing
    the if/else.

    Thanks,
    Rob

    <script type="text/javascript">
    var ssArray = new Array();
    function readCookie()
    {
    for ( var i=801; i <= 900; i++ )
    {
    ssArray.push( document.getElementById("ss"+i) );
    }
    for (var i = 0; i < ssArray.length - 1; i++)
    {
    var the_cookie = document.cookie;
    the_cookie = decodeURIComponent(the_cookie);
    if ( the_cookie.match( ssArray.id + "=c" ) )
    document.getElementById(ssArray.id).src = "ls_files/
    done.gif";
    else
    document.getElementById(ssArray.id).src = "ls_files/
    not_done.gif";
    }
    checkMajor();
    }
    </script>
     
    Rob, Mar 16, 2007
    #1
    1. Advertising

  2. Rob

    Brian Kendig Guest

    Check your browser's error console to see if it's logging any problems
    with the JavaScript.
     
    Brian Kendig, Mar 16, 2007
    #2
    1. Advertising

  3. Rob

    Rob Guest

    On Mar 16, 2:04 pm, "Brian Kendig" <> wrote:
    > Check your browser's error console to see if it's logging any problems
    > with the JavaScript.


    I figured out the problem. Some elements in my array were not defined,
    so before pushing them onto the array, I just had to add a line to
    test whether they were defined:

    <snip>

    if (document.getElementById("ss"+i));
    ssArray.push( document.getElementById("ss"+i) );

    </snip>

    Thanks for the idea about the error console. Found a cool shortcut to
    access it (called the JavaScript console) in Firefox:
    chrome://global/content/console.xul
     
    Rob, Mar 16, 2007
    #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. =?Utf-8?B?U2FuZHk=?=

    Code to Exit Web App and Exit Internet Explorer

    =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    7,940
    =?Utf-8?B?U2FuZHk=?=
    Aug 5, 2005
  2. Marc Miles

    Exit Custom Server Control Early

    Marc Miles, Aug 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    360
    Marc Miles
    Aug 17, 2005
  3. Jonathan Bartlett

    Using exceptions for early exit

    Jonathan Bartlett, Dec 12, 2005, in forum: Java
    Replies:
    37
    Views:
    1,176
    Oliver Wong
    Dec 16, 2005
  4. gcash
    Replies:
    0
    Views:
    468
    gcash
    Feb 20, 2004
  5. Sara

    A non-loop block early exit?

    Sara, Feb 10, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    122
    David K. Wall
    Feb 10, 2004
Loading...

Share This Page