views:

31

answers:

2

Hello,

I would like to make a image randomizer/slider that randomly displays an image from a designated gallery and has controls to view the next/previous image. I have seen this done where images must be coded into arrays, but I would like to be able to just drop images into a /img/gallery directory and have the randomizer/slider pull random images from that directory.

Could anyone offer some guidance on how to do this, possibly using jQuery, or refer me to a tutorial that does something like this?

A: 

Not a jQuery programmer but seems like you could do this:

  1. Determine the number of images in your directory (N)
  2. Choose a random number between 1 and N
  3. Load up that image and whatever else you need for the next/previous stuff
John at CashCommons
jQuery is client side only (javascript), so there's no way for it to read the servers side directory. Otherwise, yes.
Matt Ellen
I learned something today. Thanks!
John at CashCommons
+1  A: 

You would need to use a server-side technology like PHP, ColdFusion, or ASP.NET to read the directory images into an array or list...

pseudocode:

Get Directory Images > Put them in an array > select random values from array
JKirchartz
Agreed. You need to get the list from the server side.
Matt Ellen