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

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

<Test Script Below>


<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

<Test Script Below>


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

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site