Forum Moderators: open

Message Too Old, No Replies

Can't figure out setInterval and clearInterval code

         

Darkest Edge

3:18 am on Apr 1, 2005 (gmt 0)



Below is the code I wrote. The setInterval just does not work. It only works once all the if-statements are gone.

<script>
count=1;
name="";
function f1()
{
shutdown = setInterval("pict()",2000);
if (count=7) clearInterval(shutdown);
}

function pict()
{
document.getElementById(1).src="gallery/image"+count+".jpg";

if(count=1) name='Home';
if(count=2) name='Chapter';
if(count=3) name='Download';
if(count=4) name='Fan Art';
if(count=5) name='Friends';
if(count=6) name='Store';
if(count=7) name='FAQ';
document.getElementById(2).innerHTML=name;
count++;

}
</script>

SpaceFrog

7:04 am on Apr 1, 2005 (gmt 0)

10+ Year Member



if(count=7) is always tru because you are not comparing values but assinging value to variable

if (count==7) will return true if count is equal to 7 and false if not