![]() |
|
|
Generate a Random Picture with ASPWe first need to create a random number to use this script between the number of images that we are going to use, so yes you have guessed it , if you are going to use 5 images then obviously we need to create a random number between 1 and 5.
To create a number between 0 and 1 we can use the Rnd
function. So to create a number between 1 and 5 we must use the
line of code below in red. If you have 10 images then you would
just change the value of the HighestNumber to 10. Have a look at the following code. <% So having written the code that will get us a random number I am going to use the SELECT CASE function to select a banner or image. I have also put a hyperlink behind the banner/image. <%
You can change the links and substitute your own banner/images
names. <!--#include file="banner.asp"--> Using an include file makes the whole thing easier to maintain.
Just modify the banner.asp file, and all the pages on your site
are updated. <!--#include virtual="/banner.asp"--> In Part 2 of Generate a Random picture with ASP we show you a real example that this site uses.
Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|