In its simple form the If statement is rather limiting, enabling us
to perform one of two actions. One action if the condition is met and
another action otherwise.
<%
If request.form("Activity") = "shopping" then
...
Else
...
End If 'request.form("Activity") = "shopping"
%>
Using the Elseif option we are able to implement a number of options.
<%
If request.form("Activity") = "shopping" then
...
Elseif request.form("Activity") = "swimming" then
...
Elseif request.form("Activity") = "gardening" then
...
Elseif request.form("Activity") = "cinema" then
...
Else
...
End If 'request.form("Activity") = "shopping"
%>
In the above example each test is performed in turn. The first
one where the criteria is met is the one which is then actioned.
Beware, when using the elseif statement. Depandant upon the
form of the test care may be necessary in setting the tests out in the
correct order. For example if we are testing for the appearance
of a word or phrase within a variable, It may be the case that both
will qualify but the first one encountered will be the one actioned.
<%
activityString="flight"
if activityString="light" then
...
elseif activityString="flight" then
...
End if 'activityString
%>
Where one word is a subset of another it is usually better to put the test for the longer word first.
| This article viewed: 1377 times | Back |
Copyright © 2004-2007 Janet Systems Ltd.