PDA

View Full Version : Need random image loader



ilovesd90macs
02-05-2007, 03:32 AM
Hi, I know I have seen this script somewhere here before, but I can't find it. The script I need is a script that randomly selects an image from a certain folder and diplays it. Each time you refresh, a different picture is displayed, but until you refresh it stays the same. Thanks for any help. :)

thetestingsite
02-05-2007, 03:35 AM
Was it a client side script (javascript) or server-side (PHP,ASP,etc.) I could probably write something up in PHP, but it may take a little while (about 20 or so minutes to write, and test).

ilovesd90macs
02-05-2007, 04:34 AM
I don't know what it was, whichever works best. It was something you added into the .html file, so it is probably client side.

ilovesd90macs
02-05-2007, 04:58 AM
I have found a website with something similar to what I want. The website www.railcarphotos.com has a random feature that will show you ten random train car photos, and each time you refresh, the ones displayed change. http://www.railcarphotos.com/Search.php?Order=Random&Search=Search

The only thing is, all I want to use this for is to have my websites banner change every time that someone visits the page.

I think what the person who asked the first time I saw this a while back was trying to do was to randomly generate adds, so that a different ad was displayed each time, so the ad wasn't the same every time.

ilovesd90macs
02-05-2007, 05:24 AM
Found a better example, http://www.pwrs.ca/ The main image changes on refresh.

Twey
02-05-2007, 05:48 AM
<script type="text/javascript">
window.onload = function() {
var randomImages = [
"folder1/image1.png",
"folder2/image2.jpg",
"folder2/image3.gif",
"folder3/image4.tga"
];
document.images['random_image'].src = randomImages[Math.floor(Math.random() * randomImages.length)];
};
</script>
</head>
<body>
<img id="random_image" src="defaultImage.png">I had to answer this purely because it's 0547, my vision's getting a little blurry, and I read the "random" in the title as "condom."

jscheuer1
02-05-2007, 05:52 AM
I had to answer this purely because it's 0547, my vision's getting a little blurry, and I read the "random" in the title as "condom."

You need more than rest then.

Twey
02-05-2007, 06:02 AM
You're not wrong.

thetestingsite
02-05-2007, 03:42 PM
I read the "random" in the title as "condom."

Wow, that's just...wow. My opinion is you need sleep. ;)

Twey
02-05-2007, 05:48 PM
Twelve hours later, still no sleep. :)

Oh well, maybe soon.

jscheuer1
02-05-2007, 07:33 PM
Twelve hours later, still no sleep. :)

Oh well, maybe soon.

Are you taking pills? Drinking much caffeine? And/or, is it the mental stimulation that is keeping you awake?

Are you in a war zone?


Originally From Chairman Mao
When you're hungry, eat. When you're tired, sleep.

Even a tyrant can be right about some things, especially when they get posthumously attributed to them.

mburt
02-05-2007, 07:50 PM
I read the "random" in the title as "condom."
Haha... Either that you're sleep deprieved or your mind is being influenced by today's sexually targeted society :p

Twey
02-05-2007, 08:13 PM
Are you taking pills? Drinking much caffeine? And/or, is it the mental stimulation that is keeping you awake?No, no, and probably. :)

I've a visitor due to arrive within the next hour, so I'll sort that out then try to catch some sleep (since I'm actually feeling sleepy now, rather than just exhausted).