KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

Subroutines and Functions

We can change the flow sequence by using Subroutines and or Functions. We call a subroutine, which does its processing and then returns and we continue executing the statement after the subroutine call. The following example using two functions to calculate hotel, car and meal costs based on number of days on the trip.

FunctionForm.asp

<htmL>
<head>
<title> Function form</title>
</head>
<body>
<h2> cost calculator for <br>
Visiting Disney World Trip</h2>
Please provide the following information so we can estimate your costs:
<form action="FunctionAction.asp" method=post>
Please type your preference Hotel in location, either city or suburb:
<input type=text name="location"><br>
<input type=submit>
<input type=reset>
</body>
</html>

FunctionAction.asp

<html>
<head>
<title>Function Action</title>
</head>
<body>
<%
Function CityCost(NumberDays)
varHotelTotal=NumberDays*175
varMealsTotal=NumberDays*75
varAirportTransport=85
CityCost=varHotelTotal+varMealsTotal+varAirportTransport
end function

sub Suburbcost(numberDays)
varHotelTotal=NumberDays*85
varMealsTotal=NumberDays*45

cost=varHotelTotal+varMealsTotal
response.write "The "+ numberDasy+" day trip will cost $" & cost & "<br>"

end sub

varLocation=request.form("location")
%>
<h3> you hvave chosen the hottel in <%=varLocation%> <br>
Your estimated costs for this trip will be </h3>
<%
select case varLocation
case "city","City", "CITY"
varCost=CityCost(2)
response.write "The two day trip will cost $" & varCost &"<br>"
varCost=CityCost(4)
response.write "The four day trip will cost $" & varCost & "<br>"
varCost=CityCost(6)
response.write "The six day trip will cost $" & varCost & "<br>"
case "suburb","Suburb","SUBURB"
suburbcost(2)
suburbcost(4)
suburbcost(6)

case else
Response.write "input Error="+varLocation

end select
%>
</body>
</html>

ASP tutorial
What is ASP
Install IIS
VBScript or JScript
ClientSide vs ServerSide scripting
ASP execution order
Dealing with Form
More Form example
Variable &Variant
String
Local variable
Global variable
Arrays
Use if_then_else
Use Select Case
For_Next loop
Do_while loop
Subroutine vs Function
Request Object
QueryString
Count Keyword
Using QueryString
Application, Method, Events
Create Virtual Directory
Save array in Application
Session, Method, Events
Using Cookie
Server Object
Ad Rotator
Content Linker
Browser
Dictionary object
Filesystemobject Object

 

 

 

Best books about ASP & ASP.Net from Amazon
Beginning Dynamic Websites : with ASP.NET Web Matrix (Programmer to Programmer) (Paperback) Build Your Own ASP.NET Website Using C# & VB.NET (Build Your Own) (Paperback) Professional Active Server Pages 3.0 (Programmer to Programmer) (Paperback) ASP.NET Cookbook (Paperback) ASP.NET Kick Start (Paperback)

 

Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © kidslovepc.com All rights reserved(new). Privacy|Copyright
designed by info@kidslovepc.com

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer