home *** CD-ROM | disk | FTP | other *** search
- <%
- '*******************************************************
- '* ASP 101 Sample Code - http://www.asp101.com *
- '* *
- '* This code is made available as a service to our *
- '* visitors and is provided strictly for the *
- '* purpose of illustration. *
- '* *
- '* Please direct all inquiries to webmaster@asp101.com *
- '*******************************************************
- %>
-
- <%
- ' Declare our variable
- Dim iChoice
-
- ' Read in the choice the user clicked on.
- ' This will equal "" (an empty string) if no choice is there
- iChoice = Request.QueryString("choice")
-
- ' Execute the appropriate branch based upon the value of the variable we just read in.
- Select Case iChoice
- Case "1"
- %>
- <H3>This is what happens when you click on Case 1</H3>
- <%
- Case "2"
- %>
- <H3>This is what happens when you click on Case 2</H3>
- <%
- Case "3"
- %>
- <H3>Surprise, Surprise, This is what you get when you click on Case 3</H3>
- <%
- Case Else
- ' This executes if no of the other conditions are met!
- ' This actually runs the first time through when the user
- ' arrives at this page because the choice is blank.
- End Select
-
- ' You might also notice that in the above cases I was comparing the value of iChoice
- ' to strings containing numbers and not to the actual numerical values 1, 2, and 3.
- ' If I wanted to use the numerical values I should technically convert iChoice to a
- ' number before doing the comparison because 3 is really not the same as "3". VBScript
- ' will let you get away with it occasionally, but it's good practice to actually do the
- ' conversion and, as an additional benefit, doing so will also help avoid confusion
- ' when people are reading your code. CInt or CLng is the appropriate command:
- '
- 'Select Case CInt(iChoice)
- ' Case 1
- ' ...
- ' Case 2
- ' ...
- ' ...
- 'End Select
- %>
- Click on the different cases below:<BR>
- <A HREF="./case.asp?choice=1">Case 1</A>
- <A HREF="./case.asp?choice=2">Case 2</A>
- <A HREF="./case.asp?choice=3">Case 3</A>
-