:: Personal website of a Toronto web designer
Howto » ASP » Random Image
This is an example of ASP code that generates a random image out of four. You can always add more by setting "HNum" variable to a higher number and adding image names respectively to the "imgArr" array.
<%
Dim imgArr, LNum, HNum, RNum
' Add names of your images in the array bellow
imgArr = array("1.gif","2.gif","3.gif","4.gif","5.gif","6.gif")
Randomize
LNum = 0
HNum = 5
RNum = INT((HNum - LNum + 1) * Rnd + LNum)
Response.Write("<img src=""" & imgArr(RNum) & """ alt="""" />")
%>

