need help with script for random images
i have to load random images on a page...
ther are 5 sets of images and about 15 images in each set
set 1 contains imga1, imga2, imga3, imga4, imga5, ...
set 2 contains imgb1, imgb2, imgb3, imgb4, imgb5, ...
and so on for 3 more sets
on page load, i want to display in a random order, images from any 1 set...
so if its from set 2, it should load
imgb5, imgb6, imgb9, imgb3, imgb1, ...
if its from set 3, it should load
imgc4, imgc3, imgc7, imgc2, imgc8, ...
each image has to be from the same set
and it shouldnt repeat
can anyone help???
also...
if i have to load on the same page omages from set 1 in 1 div
and from set 2 in another div, is it possible?
works but need a little more help
thanx peter
it works... but i would like to randomly load images in the individual sets...
so if ther r 5 imgs in a particular set...
each time the page is loaded, any one of the images has to be displayed
n then after a set duration of may be 5 seconds... another image from the same set has to be loaded....
i m trying to work on this part... using the same logic that is used to randomly load a particular div... but not getting things right with the timer...
in case u can.. please help
3 separate sets of random images
I tried Peter Nguyen's code (including below version) and, for the life of me, could not get it to work. I'm missing some sort of comprehension here. Where do you specify image array? Could some kind soul clue me in?
http://artdemo.tripod.com/indexRandom3.html
<script language="javascript" type="text/javascript">/*EDITED VERSION*/
/* Random Image Set by Peter Nguyen Dynamic Drive Forums User: tech_support Visit: www.dynamicdrive.com/forums This note must stay intact for legal use */
var slide0 = new Array ();
slide0[0] = "critters/rembrantGirlBroom.jpg";
slide0[1] = "floral/cezanne.chrysanthemums.jpg";
slide0[2] = "floral/vanGogh12sunflowers.jpg";
slide0[3] = "floral/vanGoghSunflowers.jpg";
slide0[4] = "scenes/vanGogh.gif";
slide0[5] = "scenes/cole.jpg";
var slide1 = new Array ();
slide1[0] = "chanit/things/AnemonaesWC.jpg";
slide1[1] = "chanit/things/floralApples.jpg";
slide1[2] = "chanit/things/floralRecycle.jpg";
slide1[3] = "chanit/things/floristDozen.jpg";
slide1[4] = "chanit/things/moreAnemonaes.jpg";
slide1[5] = "chanit/things/Neighbors.jpg";
var slide2 = new Array ();
slide2[0] = "critters/rembrantGirlBroom.jpg";
slide2[1] = "floral/cezanne.chrysanthemums.jpg";
slide2[2] = "floral/vanGogh12sunflowers.jpg";
slide2[3] = "floral/vanGoghSunflowers.jpg";
slide2[4] = "scenes/vanGogh.gif";
slide2[5] = "scenes/cole.jpg";
var slideSetId = new Array(); //Slide Set Array
slideSetId[0] = "slide0" //Slide Set 0
slideSetId[1] = "slide1" //Slide Set 1
slideSetId[2] = "slide2"
//Add more in the form of slideSet[number] = "your id here"
var slides = 2 //How many slides there are
function initSlideSet() {
slides1 = slides+1
slideSetCount = Math.floor(Math.random()*slides1)
document.getElementById(slideSetId[slideSetCount]).style.display = 'block'
}
window.onload=initSlideSet
</script>