The most flexible way is to get a directory listing, then select one of
the files randomly. One additional advantage is that you don't have to
use a special file naming convention unless you've mixed the photos in
the same directory with others that you _don't_ want in the rotation.
You also needn't know ahead of time how many files there will be.
<cfdirectory action="list"
directory="d:\web\graphics\photos\"
name="photos"
filter="*.jpg">
<cfif photos.recordcount>
<cfset dummy = Randomize(GetTickCount())>
<cfset myphoto = photos.name[RandRange(1, photos.recordcount)]>
</cfif>
Jim
-----Original Message-----
From: Carlo van Wyk <[EMAIL PROTECTED]>
To: CF-Talk <[EMAIL PROTECTED]>
Date: Wednesday, July 04, 2001 11:13 AM
Subject: Random images from directory
>I need to display random images from a directory. (Almost like a Ad
>rotator.) There will probably be about 100 .jpeg files in the directory
ata
>a time, and they will be in the format 1.jpg to 100.jpg
>
>How can one display the images randomly?
>
>Regards
>Carlo
>
>Archives: http://www.mail-archive.com/[email protected]/
>Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists