Sha Crawford wrote:
I have a series of images called shacam1, shacam2..... shacam(n) I
want these to appear on my blog as if they were a feed from a webcam. I
need a little piece of code to select a random image to start from and
to then cycle through the images in order, refreshing every 5000ms.
Help?
I'll give you a few hints.
When the page is loaded, you want to:
* Load the list of images
* Pick a random offset
* Load the next image. This task consists of:
* Setting your <img> element's src attribute
* Advancing the offset into the list by 1, resetting it to the
beginning if it's at the end of the list
* Setting a timer to load the next image 5 seconds later
If I'm understanding your question correctly, that's almost a
line-for-line translation of the JavaScript for achieving what you
want. Now go do some research and implement it yourself. The
setTimeout() and Math.random() functions and the % operator will be
particularly useful.
-- David