Example2: Now assume that for this baseball, everyone
needs a team uniform. Your task is to collect size,color from team
players.
Programming used: CollectInformation.asp, DealCollection.asp
CollectInformation.asp
<html>
<head>
<title> Form for Uniform</title>
</head>
<body>
<H1> Base ball uniform</h1>
<h3>Please fill in this form and press submit</h3>
<Form action="dealcollection.asp" method=post>
Your name<input type="text" name="name">
Your size:S, M, L, XL:<input type="text" name="size"></p>
Your color <input type="text" name="color"></p>
<Input type="reset" value="Start over">
<input type="submit" value="Save my preferences" ></p>
</form>
</body>
</html>
How it works: The above code produces 2 text boxes
named "size" and "color", along with Submit and Reset button. The
resulting form is send to DealCollection.asp.
DealCollection.asp
<html>
<head>
<title>Uniform information</title>
</head>
<body>
<%
Dim strName,strSize,strColor
strName=Request.Form("name")
strSize=Request.Form("size")
strColor=Request.Form("color")
%>
<h1>BaseBall uniform Order
</h1>
<% Response.write strName %> ordered the following uniform:<br>
Color= <% Response.write strColor %><br>
Size=<% Response.write strSize %><br>
</body>
</html>
How is works:
Name size and color are passed in the form object and saved in local
string variables: strName,strSize and strcolor. The information
is then displayed using the Response.Write method.
Saving the information
In the previous example we saved the information as follows:
<%
Dim strName,strSize,strColor
strName=Request.Form("name")
strSize=Request.Form("size")
strColor=Request.Form("Color")
%>
We retrieve the information from the Form object by using Request.Form(XXX)
and save it in the local variables for later use. Displaying the information back to user
In the DealCollection.asp we displayed the saved information using
the Response.write method as follows:
<%Response.write strName%>
<%Response.write strSize%>
<%Response.write strColor%>
|