Random image with duplicate checker

K

KoRnDragon

I need a Javascript function that will display X random images on a
page that also doesn't display the same image twice.

Bonus points if it grabs the max array from the folder and sets it.
Even more points if it grabs all the image names from the folder.

Thanks in advance!
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Mon, 18 Sep 2006 15:01:24 remote, seen in
news:comp.lang.javascript said:
I need a Javascript function that will display X random images on a
page that also doesn't display the same image twice.

Then they are not random. See FAQ 4.22 and its final link.
Bonus points if it grabs the max array from the folder and sets it.
Even more points if it grabs all the image names from the folder.

Under normal security, Web Javascript has no such access to folders. If
the image folder on the server has no default page, you might be able to
access it in to another frame or window as a directory and read that by
Javascript. ISTM better to use a process on the authoring or serving
machine to produce a list of image names; or to name the images
systematically, e.g. pic0000.gif to pic0121.gif.

In the latter case, you need only determine the number (N) of images
available, deal X of N, and use the results to generate the names
directly; otherwise to index a name array.

It's a good idea to read the newsgroup and its FAQ.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top