Click to See Complete Forum and Search --> : random image script


redsand198
07-15-2003, 07:53 AM
i have this page:

http://antachmotorsports.com/avi/home.html

and the image in the right bottom frame changes when you click on it.

how do i make a script so that the image changes automatically every 6 seconds or so?

thank you very much

Khalid Ali
07-15-2003, 09:48 AM
put all of the images in an array say

var imgArr = new Array();

thenonload event of the body tag call a function say load images

<body onload="loadImages();">

now in javascript section of your page

<script type="text/javascript">
var ctr=0;
function loadImages(){
// show image here
document.getElementById("imgId").src = imgArr[((ctr<imgArr.length)?ctr:(ctr=0))].src
setTimeout('loadImages()',6000)//1000 = 1 second

}

hope this helps