ASP Example #4 - Random Images
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017
Once Again: This tutorial deals with ASP. I do not have the ability to run ASP on my server so you'll need to take this stuff and run it on yours to get the effect. I have run this on an ASP server so I know it works. If you're not sure if your server has ASP capabilities, go to the first ASP tutorial and get the little test script to find out.
When I asked my ASP/VBScript wizard to write some scripts that I could hand out as examples, the one I wanted straight away was an image, or banner, randomizer. It's a pretty popular effect. When he quoted me the price to write the script, I expected something rather ornate. Nope. He did this one in about 20 seconds. That dirty, rotten...
To get the effect, you need the script and a bunch of like images. By "like", I mean the same size. This script is set up to choose between six different images. It looks like this:
Response.write("<IMG SRC='randompicture" & INT((6)*RND()) & ".gif'>")
You're seeing the script in the shortened form. The original included a lot of extra attributes describing the image:
You might have grasped this already from the script, but the names of these images will all be "randompicture#.gif". See the INT((6)*RND())? That is code that will randomly choose a number between one and six. Reading it from right to left, the script writes an Image tag to the page and sets the SRC to read "randompicture", and chooses a random number, and then adds the .gif.
So, in order to use this script, you paste it in where the random image will go. Then, in the same directory, you offer the images it will need to choose from. In the case of this script, you'll need six images named randompicture1.gif through randompicture6.gif.