ASP Forms Get
When you pass information from
an HTML form, using the Get
method, to an ASP page from
processing, you can retrieve the
information using ASP's
QueryString Collection. In the
previous lesson we created "codetellerForm.html"
that sent information to "codetellerGet.asp"
for processing. Below is that HTML
code.
codetellerForm.html Code:
<form method="GET" action="codetellerGet.asp">
Name <input type="text"
name="Name"/>
Age <input type="text"
name="Age"/>
<input type="submit" />
</form> |
Now we need to create our ASP
web page "codetellerGet.asp" that
will process this data.
ASP QueryString Variables
The form data we want resides
within the Request Object's
QueryString collection. In this
collection there is an entry for
each individual Form Input from
our HTML Form. The input tag's
name attribute is the key needed
to access data for that Input
element.
Here we create a simple ASP
processor that will store the
contents of each the two items in
our QueryString into variables and
then print their values to the web
page.
Save your ASP file as "codetelleGet.asp"
and save it in the same directory
as "codetellerForm.html".
codetellerGet.asp Code
<%
Dim name, age
name =
Request.QueryString("Name")
age = Request.QueryString("Age")
Response.Write("Name: " & name
& "<br />")
Response.Write("Age: " & age &
"<br />")
%> |
ASP Get Simulation
After you have saved both files
into a working ASP directory then
if you were to enter the following
information into "codetellerForm.html"
and submit you would get the
following:
codetellerForm.html Filled
Out:
asp-forms-get.asp Result:
|
|
|
|