Padding Padding
Janet
Systems
 Register  Login 
Telephone  01628 566 178
Website Design, Hosting and Software Services
  Search 
Padding
corner Padding corner
Padding Padding
corner Padding corner
 ASP Articles

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.

 Print   

DotNetNuke Website design and hosting from £15.00 per month. More...

Looking for a website design company in the Thames Valley, call us on 01628 566178

DotNetNuke Modules
DotNetNuke Modules availalble from Janet Systems

DotNetNuke Skins
DotNetNukeSkins.gif

from Janet Systems

Padding
Copyright 2002-2008 Janet Systems Ltd.   Terms Of Use  Privacy Statement Tuesday, May 13, 2008