Click to See Complete Forum and Search --> : Random image with corresponding text


javahelpme
03-24-2003, 02:20 AM
It would look something like a random image and text that correspond to each other in an array of image and text sets that appear randomly on the refresh of a page. For instance everytime a picture named deer.gif would appear out of the generator, the text "reindeer" would always appear under it and when ever another picture named santa.gif would appear, the text "claus" would appear under it.

Please somebody help me find a script that can do this. I'm sure it must be possible to create, but I've been looking for some time now and still can't find one. Someone please help me out here. :o Many thanks to anyone who can be of some assistance.

If you know of no such script, then I challenge you to make one for me. :p

khalidali63
03-24-2003, 07:49 AM
Here is a way of doing this.
create an array of image paths and text underneath them.

var imgArray = new Array(
new Array("deer.gif","reindeer"),
new Array("santa.gif","claus"))

at this point the array length is only 2 so we will get a random number generated withing this limit.

var index = Math.random() * imgArray.length;

then you pass this index to image array and get the values

imgURL = imgArray[index][0];
imgText = imgArray[index][1];

And the rest should be fairly easy.

create an image object display it and dislay text underneath it.

Cheers

Khalid

javahelpme
03-24-2003, 12:30 PM
Thanks so much khalidali63! I can take a shot at it now. :)