Click to See Complete Forum and Search --> : Changing Pictures on a website


ultra_lime
10-02-2003, 08:34 PM
ive been to a website where i can go one minute and see a picture on the top and go there again the next minute and have a diffrent picture and so on. how did they do that? i think what would be nice on my website.
thanks
"A"

devalt
10-03-2003, 11:25 AM
Is it an ad rotator or just a random image? Also what technology are you wanting to use?

devalt
10-03-2003, 11:45 AM
Example of how to do it using javascript:


<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
var theImages = new Array()

theImages[0] = '1.gif'
theImages[1] = '2.gif'
theImages[2] = '3.gif'
theImages[3] = '4.gif'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
</script>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
showImage();
</script>
</body>
</html>

Dan@354-Pines
10-03-2003, 12:48 PM
<script language="JavaScript" type="text/javascript"><!--
function makeArray(len)
{
for (var i = 0; i < len; i++) this[i] = null;
this.length = len;
}
// This is where the array of imagesis created.
wwwRand = new makeArray(3);
wwwRand[0] = "<img src='images/photos/image1.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image1'>";
wwwRand[1] = "<img src='images/photos/image2.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image2'>";
wwwRand[2] = "<img src='images/photos/image3.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image3'>";

// The random number generator.
function rand(n)
{
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 6) % n;
}
</script>

skinsfan44
10-07-2003, 01:19 PM
http://www.hiveware.com/imagerotator.php

naper2000
10-09-2003, 06:49 PM
Yup... i know its kool!!!

i think the people already sumed it up. I read bout that in my java book over the summer too. You could use it for all sorts of stuff like pics, words, quotes, and anything else you can think im pretty sure. Starcraft Legacy (http://www.sclegacy.com) has a quote generator i think sorta like your picture generator!\

Have fun with your new found knowledge:D

charroBOB
10-12-2003, 03:40 AM
These Guys (http://www.chipmunk-scripts.com/scripts/imagerotater.php) have it down to like, 10 lines of PHP..

cheers!