Function seems to exit early

R

Rob

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>
 
B

Brian Kendig

Check your browser's error console to see if it's logging any problems
with the JavaScript.
 
R

Rob

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top