ASP and HTML Form Dynamic Web page production

Source: Internet
Author: User
Tags html form

In ASP, there are two very common collections, one is Request.QueryString, the other is Request.Form. These two collections can get information submitted by HTML Forms (HTML forms).

Request.QueryString

There are two kinds of method in an HTML form, one is get and the other is post. When an HTML form is method= "get", you can use Request.QueryString to obtain information about the form submission.

The following is an example of an HTML form that lets users enter names.

<form action= "yourname.asp" method= "Get" >
Please enter your name:
<input type= "text" name= "Yourname" >
<input type= "Submit" value= "submitted" >
</form>
The information submitted.

In the example, the method used in the HTML form is get, and the page that points to the action is an. asp file with the name yourname.asp. The following is the source code for the yourname.asp file:

<title> Name Information </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<p> your name is: <%= request.querystring ("Yourname")%></p>
</body>
In this. asp file, you can see that the most critical code is:

<p> your name is: <%= request.querystring ("Yourname")%></p>

The "Yourname" in the request.querystring brackets corresponds to the name value of the Input entry box in the HTML form.

When submitting form information using method= "Get", users can see these submissions from the address bar.

Request.Form

When method = "POST" in an HTML form, you can use Request.Form to get information about the HTML form submission.

Collection). Request.Form.

The following is an example of an HTML form that lets the user enter a name and password.

<form action= "userpw.asp" method= "POST" >
Please enter your name: <input type= "text" name= "Yourname" ><br>
Please enter your password: <input type= "password" name= "YOURPW" ><br>
<input type= "Submit" value= "submitted" >
</form>
(index) can refer to Request.Form?

In this example, the method used in an HTML form is post, and the Web page that points to the action is an. asp file with the name userpw.asp. The following is the source code for the userpw.asp file:

<title> User Information </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<p> your name is: <%= request.form ("Yourname")%></p>
<p> your password is: <%= request.form ("YOURPW")%></p>
</body>
In this. asp file, you can see that the two most critical lines of code are:

<p> your name is: <%= request.form ("Yourname")%></p>
<p> your password is: <%= request.form ("YOURPW")%></p>
The "Yourname" and "YOURPW" in the request.form brackets correspond to the name values of the two input input boxes in the HTML form.

Count, you can get the total number of values for an element in the collection. There are two very common collections.

There are also form controls available to the user in the HTML form, such as the Radio box input type= "Radio", the checkbox input type= "checkbox", the Single Drop-down box select, and the Check drop-down box select multiple.

(Element) (index) can be referenced.

Examples of these optional controls. In these examples, the. asp file that the action points to is called choose.asp. The following is the source code for the choose.asp file:

<title>retrieve Information from form controls (radio, checkbox, select) </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
You chose:<br>.
<% for counter = 1 to Request.Form ("fruit"). Count
Response.Write Request.Form ("fruit") (counter) & "<br>"
Next
%>
</body>
The following is an example of an HTML form that lets the user enter a name and password. You can get the total number of values for an element in the collection.

Request.Form Gets a collection (collection). The Request.Form collection has two parameters, one is element, the name of the HTML form control, and the second is index, which indicates the value of the element, and the index counts from 1.

Request.Form (Element) (index) can refer to a value of an element in the Request.Form collection.

Get, you can use Request.QueryString to obtain information about the form submission.


For example, Request.Form ("Fruit") (1) represents the first value in the "fruit" element, and Request.Form ("Fruit") (2) represents the 2nd value in the "fruit" element.

Use Request.Form (Element). Count, you can get the total number of values for an element in the collection.

such as Request.Form ("fruit"). If Count is 3, it means that the element "fruit" has 3 values.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.