Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Function seems to exit early

0 views
Skip to first unread message

Rob

unread,
Mar 16, 2007, 3:57:13 PM3/16/07
to
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>

Brian Kendig

unread,
Mar 16, 2007, 4:04:47 PM3/16/07
to
Check your browser's error console to see if it's logging any problems
with the JavaScript.


Rob

unread,
Mar 16, 2007, 4:42:05 PM3/16/07
to
On Mar 16, 2:04 pm, "Brian Kendig" <b...@enchanter.net> 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

0 new messages