Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Function seems to exit early

Reply
Thread Tools

Function seems to exit early

 
 
Rob
Guest
Posts: n/a
 
      03-16-2007
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[i].id + "=c" ) )
document.getElementById(ssArray[i].id).src = "ls_files/
done.gif";
else
document.getElementById(ssArray[i].id).src = "ls_files/
not_done.gif";
}
checkMajor();
}
</script>

 
Reply With Quote
 
 
 
 
Brian Kendig
Guest
Posts: n/a
 
      03-16-2007
Check your browser's error console to see if it's logging any problems
with the JavaScript.


 
Reply With Quote
 
 
 
 
Rob
Guest
Posts: n/a
 
      03-16-2007
On Mar 16, 2:04 pm, "Brian Kendig" <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows X64 Trial Ended, but seems early =?Utf-8?B?VG9t?= Windows 64bit 22 12-17-2005 07:58 PM
Using exceptions for early exit Jonathan Bartlett Java 37 12-16-2005 08:28 PM
Exit Custom Server Control Early Marc Miles ASP .Net 2 08-17-2005 05:20 PM
jython: how do you exit an applet early? gcash Python 0 02-20-2004 03:17 AM
A non-loop block early exit? Sara Perl Misc 4 02-10-2004 08:20 PM



Advertisments