![]() |
|
|
Published: Friday, August 20, 1999 By Ronnie Tantriady Have you ever got bored looking at same picture everytime you visit a particular web page? A friend of mine who owns a travel agency was worried if regular visitors of his website would be bored looking at the same static picture. On the other hand, he has already collected about 950 scenic pictures of world cities in both JPEG and GIF format. So how do we help him make a web page that will display one of those pictures randomly everytime a visit is made to his ASP enabled website?
Simple. First, I created a new directory in his web server and copied all of the
JPEG and GIF pictures into it. For obvious reasons I named the directory
Next, I created the following ASP file, and saved it as
Let's take a look at the code.
We created an array of size 1000, which is more than enough to store the file names of those 950 JPEG and GIF files.
These lines instruct the server to grab the filenames of all files resided
in the folder called
Transfer each and every file name to the array we defined above, and
at the same time count the number of actual files found in the
Generate a random number between 1 to the number that matches the actual
number of files found in the
Close the file system objects.
Generate an HTML line to display the picture at 97% the height of the browser window. Amazingly simple, isn't it? Happy Programming!
Attachments: RandDisp.asp in text format
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|