Hey, basically I need a script that I can put on my site that displays a random image, and some text beneath it, that changes like, every 15 seconds or something, it's gonna be for a random room adverts.
+Rep!
Printable View
Hey, basically I need a script that I can put on my site that displays a random image, and some text beneath it, that changes like, every 15 seconds or something, it's gonna be for a random room adverts.
+Rep!
Just spent 15 minutes making that :8.Code:<script type="text/javascript">
var images = new Array();
images[0]=new Array();
images[0][0]="IMAGE URL HERE";
images[0][1]="TEXT HERE";
images[1]=new Array();
images[1][0]="IMAGE URL HERE #2";
images[1][1]="TEXT HERE #2";
function randimage()
{
var randomnumber=Math.floor((images.length+1)*Math.random());
document.getElementById('image').src = images[randomnumber][0];
document.getElementById('text').innerHTML = images[randomnumber][1];
}
function startrand()
{
randimage();
t=window.setInterval(randimage, "15000");
}
</script>
<body onload="startrand()">
<img src="IMAGE URL HERE" id="image" /><br />
<div id="text"></div>
</body>
There are probably better ways of doing it but thats one i've just done now.
http://www.designplace.org/scripts.php?page=1&c_id=13
Google goes a long way.
Simple add " <meta http-equiv="refresh" content="15"/> " to the top or bottom of the script.
or in the correct area. >_>Quote:
Simple add " <meta http-equiv="refresh" content="15"/> " to the top or bottom of the script.
thanks delatroy +rep