<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim pagename, pagename2, pageindex pagename = "gallery1" ' pagename2 = "engagements" ' pageindex = 1 ' set checking on so that we have to dimension our variables before we can use them 'Option Explicit ' dimension our variables first dim filesys, folder, folder_name_web, folder_name_drive, files_collection, filecount, filename, rand, file, i ' store the images directory name in a variable folder_name_web = "/gallery/images/"&pagename&"/" '&pageindex&"/" ' map the folder name as accessible through the web to the actual path on the hard-drive. folder_name_drive = Server.MapPath(folder_name_web) ' create a FileSystem Object and use it to get a Folder Object set filesys = CreateObject("Scripting.FileSystemObject") set folder = filesys.GetFolder(folder_name_drive) ' get a collection of all the files in the folder set files_collection = folder.Files 'get the number of files in the collection filecount = files_collection.Count ' generate a new seed for the Rnd() function 'Randomize ' generate a random number between 0 and filecount - 1 'rand = Int(Rnd() * filecount) ' get the name of the file corresponding to the random number 'i = 0 for each file in files_collection filename = file.name ' if i = rand then exit for ' i = i+1 next ' output the html %> Kate's Club - 2009 Dinner of Champions