Guest_imported
New member
- Jan 1, 1970
- 0
hello all, i am working on a script that rotates 4 images. i reckon i have got the idea right, useing if else statements to test which image is in which slot then modifying it accordingly. this loops round to test each image slot. but the script isnt working, and since none of the images are changing at all, i figure there must be something i have done wrong with the code. here is the code, any help would be appreciated.
thx
bob
<SCRIPT LANGUAGE="JavaScript">
function rotateimages2(){
for(i=1;i<=4;i++){
if(document.images["top"+i].src=="top4.jpg"{
document.images["top"+i].src="top3.jpg";
}
else if(document.images["top"+i].src=="top3.jpg"{
document.images["top"+i].src="top2.jpg";
}
else if(document.images["top"+i].src=="top2.jpg"{
document.images["top"+i].src="top1.jpg";
}
else if(document.images["top"+i].src=="top1.jpg"{
document.images["top"+i].src="top4.jpg";
}
}
setTimeout("rotateimages2()",5000);
}
</SCRIPT>
<body onload="rotateimages2()">
thx
bob
<SCRIPT LANGUAGE="JavaScript">
function rotateimages2(){
for(i=1;i<=4;i++){
if(document.images["top"+i].src=="top4.jpg"{
document.images["top"+i].src="top3.jpg";
}
else if(document.images["top"+i].src=="top3.jpg"{
document.images["top"+i].src="top2.jpg";
}
else if(document.images["top"+i].src=="top2.jpg"{
document.images["top"+i].src="top1.jpg";
}
else if(document.images["top"+i].src=="top1.jpg"{
document.images["top"+i].src="top4.jpg";
}
}
setTimeout("rotateimages2()",5000);
}
</SCRIPT>
<body onload="rotateimages2()">