|
IF statement Part3 (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, last name and salary.
filename=/learn/test/if3.asp
<html><head>
<TITLE>if3.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form action="if3respond.asp" method=get>
Your First Name<INPUT NAME="FirstName" MaxLength=20><p>
Your Last Name<INPUT NAME="LastName" MaxLength=20><p>
Your Salary <INPUT NAME="Salary" MaxLength=7><p>
<INPUT TYPE=submit><p><INPUT TYPE=reset>
</form></body></html>
This example shows how IF can deal with ranges and use
various other boolean operators.
filename=/learn/test/if3respond.asp
<html><head>
<TITLE>if3respond.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<%
fname=request.querystring("Firstname")
lname=request.querystring("Lastname")
salary=request.querystring("Salary")
response.write "Nice to Meet You " & fname & " " & lname & "<p>"
if salary>100000 then%>
Would you like to loan me some money?<p>
<%
sstaxMarginal=15
else
SSTaxMarginal=15
end if
If salary>6700 and salary<30000 then
SSTaxMarginal=0%>
Would you like me to loan you some money?<p>
<%end if
If salary<6700 then
SSTaxMarginal=0
end if
%>
By the way your marginal tax rate is <%=sstaxmarginal%>
</body></html>
|