Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Server Variables: Displaying All
     [next Lesson]  Browscap: Basics

Random Advice / Rotating Information by Charles Carroll

This page demonstrates how to use several commands together to serve varying content based on a random number:

  • RND function

  • INT function

  • SELECT CASE

The script randomadvice.asp shows different advice every time the pge is refreshed:

   filename=/learn/test/randomadvice.asp

<Test Script Below>


<html><head>
<TITLE>randomadvice.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
<% 
' generate a random number 1-6
randomize
randomnum=int(rnd*6)+1
SELECT CASE randomnum
CASE 1,2,3%>
    Plant your crops early this year<br>
    No frost expected<br>
<%CASE 4%>
    Never play cards<br>with a man named after a city<br>
<%CASE 5%>
    You can never be too rich, too thin or backup too often<br>
<%CASE 6%>
    A swallow keeps away the stork<br>
<%END SELECT%>
</body></html>

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site