Linda said:
Greetings:
I have found a random image script that I like. It is located here:
http://www.javascriptcity.com/scripts/local/simage3.htm
That script does a bad job of generating random numbers.
You can replace "one", "two", "three", and "four" with the id values of your
images, and replace the list of URLs under each one with the URLs that you want
to select from for that image. In this example, they're all the same because I
ran out of demo images. You have add any number of images with any number of
URLs for each one:
<html>
<head>
<script type="text/javascript">
var data = [ "one",
[ "http://www.azphx.com/dhtml/tmp/alpha6464.jpg",
"http://www.azphx.com/dhtml/tmp/beta6464.jpg",
"http://www.azphx.com/dhtml/tmp/gamma6464.jpg",
"http://www.azphx.com/dhtml/tmp/delta6464.jpg"
],
"two",
[ "http://www.azphx.com/dhtml/tmp/alpha6464.jpg",
"http://www.azphx.com/dhtml/tmp/beta6464.jpg",
"http://www.azphx.com/dhtml/tmp/gamma6464.jpg",
"http://www.azphx.com/dhtml/tmp/delta6464.jpg"
],
"three",
[ "http://www.azphx.com/dhtml/tmp/alpha6464.jpg",
"http://www.azphx.com/dhtml/tmp/beta6464.jpg",
"http://www.azphx.com/dhtml/tmp/gamma6464.jpg",
"http://www.azphx.com/dhtml/tmp/delta6464.jpg"
],
"four",
[ "http://www.azphx.com/dhtml/tmp/alpha6464.jpg",
"http://www.azphx.com/dhtml/tmp/beta6464.jpg",
"http://www.azphx.com/dhtml/tmp/gamma6464.jpg",
"http://www.azphx.com/dhtml/tmp/delta6464.jpg"
]
];
function randomImages(d) {
for(var i=0;i<d.length-2;i+=2) {
document.getEle mentById(d[i]).src=
d[i+1][Math.floor(Math .random()*d[i+1].length)];
}
}
</script>
</head>
<body onload="randomI mages(data)">
<h3>One</h3>
<img id="one" src="http://www.azphx.com/dhtml/tmp/alpha6464.jpg">
<h3>Two</h3>
<img id="two" src="http://www.azphx.com/dhtml/tmp/beta6464.jpg">
<h3>Three</h3>
<img id="three" src="http://www.azphx.com/dhtml/tmp/gamma6464.jpg">
<h3>Four</h3>
<img id="Four" src="http://www.azphx.com/dhtml/tmp/delta6464.jpg">
</body>
</html>