This example selects a random image from a set amount . We have a total of 6 images and in this example they are store in the images directory and have the names a1.gif to a6.gif.

Here is the code.

<%
'declare our variables
Dim pics , totalPics , picFileName
'6 images in this example
totalPics = 6
'get a random picture
Randomize
pics = Int((totalPics*Rnd)+1)
'create filename
picFileName = "images/" & "a" & pics & ".gif"
%>

now to display the random image on the page we place the following where we require the image

<img src="<%= picFileName%>">

 

 

Sponsors