|
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
<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
<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>
|