Jump to content

Random Image?


ColdEdge

Recommended Posts

Hi, a while back i found a code which uses javascript as primary ground the problem now is that i lost it and have no idea where it is could any one help me?loads random image when page is refreshed from a list of set images... will be used on MyBB forum

Link to comment
Share on other sites

Hi, a while back i found a code which uses javascript as primary ground the problem now is that i lost it and have no idea where it is could any one help me?loads random image when page is refreshed from a list of set images... will be used on MyBB forum
i don't know offhand where it is, but i know i've seen code all over this forum that does pretty much exactly what you need it to do. i would advise that until someone else posts a better answer than me, look around the javascript forum and see what you can find.
Link to comment
Share on other sites

This should work. Post back if it doesn't:

function load_image () {	var images = [];	images[0] = "image0.jpg";	images[1] = "image1.jpg";	images[2] = "image2.jpg";	// ADD AS MANY AS YOU LIKE	var index = Math.floor(Math.random() * images.length);	document.getElementById("my_image").src = images[index];}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...