Hi there,
Hope someone can help me on this. I really need help.
I have a javascript for a rotating image, whereby a total of 10 images will change automatically in every 3 seconds. It works well in a .html page, however it doesn't work in a .php page. In a .php page, only the first image appears, then it is stagnant, the rest of the images do not appear.
Can anyone please advise if the following script has any issue whereby it will not be executed properly when it's in a .php page? or, what's the reason that it couldn't work in a .php page?
Any advice is very much appreciated. Thank you so much.
My script is as below:
<script type="text/javascript">
img1 = new Image(); img1.src = "images/f95ce056343b3dbdb6606096b2123494_ybx7.png";
img2 = new Image(); img2.src = "images/6c714872e4c66a789b21e88fd90f6f03.png";
img3 = new Image(); img3.src = "images/0b2db57ccbd11c6c7a52cc10ad9aa950.png";
img4 = new Image(); img4.src = "images/9f932a67ed4a1c3dd83948b8b7afb052.png";
img5 = new Image(); img5.src = "images/d6085b0ae37acce9f85899a0fb66879f.png";
img6 = new Image(); img6.src = "images/c865d6c72544cb2590ef922c02f1b9eb.png";
img7 = new Image(); img7.src = "images/7b8e0e999dc94fe436e86b4dedfcb8ed.png";
img8 = new Image(); img8.src = "images/c5c25bc26aced3da5e5595734ca1d35d.png";
img9 = new Image(); img9.src = "images/9dd72de17f11cd33f4e9a197ddaaf417.png";
img10 = new Image(); img10.src = "images/cb69f5ea9146d20b6f52bad0e2a5c179.png";
// add as many images as you want
var howManyPics = 10; //set this to the number of pictures you have
var delay = 3; // set this to the number of seconds between each picture
//don't touch anything below here
var pic = 1;
function changePic(){
pic = (pic==howManyPics)?1:pic+1;
document.images['img'].src = eval('img'+pic+'.src');
}
</script>
</head>
<body onload="setInterval('changePic()', delay*1000);">
<img name="img" src="images/f95ce056343b3dbdb6606096b2123494_ybx7.png">