oswalsh — 2010-01-28T00:03:11-05:00 — #1
Hey Ive read through the other forums on the topic, but I haven't done this in a long time. I am just starting the project so I don't have much to show for it yet.
What I have is a site with about 10 pictures, each of these pictures needs to be randomly pulled from folders, each picture slot will have its own folder, due to it being categorized. When the picture is clicked i need it to open a new page with the document associated to the picture. Is there a way to do this without having to rewrite the code every time? Because as there are new documents added at the end of each week.
Unfortunately the server I use doesn't support PHP, but if it has to be done in PHP I can switch.
Like I said though I haven't messed around with web design in a long time, so if someone could essentially spell this out for me I would be extremely grateful.
crmalibu — 2010-01-28T00:33:19-05:00 — #2
oswalsh — 2010-01-28T00:41:19-05:00 — #3
Ok thanks, I have done random images before, and I found the code I used, the problem is that I had to specify what to randomize, with the amount of files we need to randomize it will be pretty time consuming. I'll look into learning how to do this in php then. Thanks again.
oswalsh — 2010-01-28T15:45:51-05:00 — #4
OK so I have a new problem I got the script to work, which is:
// Set up the image files to be used.
var theImages = [
var link = [
var r = Math.floor(Math.random() * theImages.length);
document.write('<A HREF="' + link[r] + '"><img width="150" height="100" src="reports/'+theImages[r] +'" border="1" ></a>');
However sometimes the images are repeated, this shows up in four different cells, I actually use quite a few more images and links, just cut them off to save space. Is there a line of code I can change to stop the random repetition, it doesn't happen often but it looks stupid when it does.