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]  Forms: CASE syntax #2
     [next Lesson]  Forms: IF syntax #2

IF statement (by John Kauffman & Charles Carroll)

Very often you must determine what to do next based on user input. This is one of the roles of the IF statement. First we make a form that will ask a user for their first name and last name.

   filename=/learn/test/if.asp

<Test Script Below>


<html><head>
<TITLE>if.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form action="ifrespond.asp" method=get>
Your First Name<INPUT NAME="FirstName" MaxLength=20><p>
Your Last Name<INPUT NAME="LastName" MaxLength=20><p>
<INPUT TYPE=submit><p><INPUT TYPE=reset>
</form></body></html>

Now we make a asp file that examines their first name and last name after the form is submitted.

   filename=/learn/test/ifrespond.asp

<Test Script Below>


<html><head>
<TITLE>ifrespond.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<%fname=request.querystring("Firstname")
lname=request.querystring("Lastname")
If fname="George" and lname="Washington" then%>
    Hi.<p>You must be the first president!
<%else%>
    Hi!<p>Nice to Meet You
<%end if%>
</body></html>

Send Us a Holiday Gift!. Charles celebrates Christmas, Jewish holidays, Kwanza, Chinese New Year, Japanese Holidays, Secretary Day, High Muslim Holy Days, Pagan & Wicca holidays, and many more! - send a gift any HOLIDAY. 2004 gift gallery & 2005 gift gallery