[thelist] javascript non-random images

Denise@i-Create.web denise at i-create.web.com
Thu Nov 24 13:16:45 CST 2005


Hello,

I have a random image javascript on my site. It rotates the images on load. I would like it to be sequential, showing the images 0, 1, 2, 3, 4 if the visitor refreshes the page, instead of random 2, 2, 2, 1, 0... 

Here's the code:

<head>

<script language="JavaScript" type="text/javascript">
<!--
var ic = 5;     
var xoxo = new Array(ic);  
        
xoxo[0] = "images/tree-sq2.jpg";
xoxo[1] = "images/birdhouse-sq.jpg";
xoxo[2] = "images/moss-sq3.jpg";
xoxo[3] = "images/road-sq3.jpg";
xoxo[4] = "images/lake-shp2.jpg"

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
var choice = pickRandom(ic);
// -->
</script>

</head>

<body>

<script language="JavaScript" type="text/javascript">document.writeln('<IMG SRC="'+xoxo[choice]+'" border="0" width="700" height="150" >');</script>

</body>

I have looked, but I just can't find a sequential javascript. Anybody have the answer?

Thanks for the help, Denise




More information about the thelist mailing list