alex3 Posted April 21, 2009 Share Posted April 21, 2009 I have two images I want to load from a folder of images, these images must match. The syntax of the image files names is headerpX.png and footerpX.png. I'd like a random set of these images to load every page load. Here's how I think might be a good way to do it n very pseudo-code $1 get number of files in images/ folder $2 get the integer of ($1/2) $3 get random number between 1 and $2 And then in my HTML code, I'd have the code <img src="images/headerp$3.png"></img> <img src="images/footerp$3.png"></img> (or however I'd embed that random number in to the src field) Is this do-able and easy code? Will the $3 number be the same if I call it twice in the HTML, or will it run the javascript again and return a different random number? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 21, 2009 Share Posted April 21, 2009 well, first JavaScript won't be able to determine the number of files in the images/ folder. you will need a serverside language for this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.