Holamundo.asp

Page source

<HTML> <HEAD> <TITLE>random test</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> The current time is 6:28:40 AM<hr><h2>Howdy, World!</h2><hr> Today's date is 8/26/2005 </BODY> </HTML>

Script listing

<HTML> <HEAD> <TITLE>random test</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> The current time is <% response.write(time() & "<hr>") dim intSel 'an integer 0, 1, or 2 randomize intSel = Int(3 * rnd()) 'select the random integer Select case intSel Case 0 response.write ("<h2>Hello, World!</h2>") Case 1 response.write ("<h2>Howdy, World!</h2>") Case 2 response.write ("<h2>Hola, Mundito!</h2>") End Select response.write ("<hr> Today's date is " & date()) %> </BODY> </HTML>

Explanation

The program portion of this page is several lines long. It writes the current time to the response object, then generates a random number (intSel) between 0 and 2.

The value of intSel determines which of three messages will be written to the response object using a Case statement.

The final response.write statement outputs the current date.

Note that this example includes only one program segment (between < and >). One may place any number of program segments in an ASP page.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.