ASP instance Tutorial: Form set

Source: Internet
Author: User

Form set

Note that this ASP instance tutorial is about form code. To save trouble, I cannot! You can test the instance execution result on your own!

Simple Application of a Form set

This example shows how to retrieve a value from a Form in the Form set. This form uses the POST method, which means that the sent information is invisible to users and there is no limit on the amount of sent information (a large amount of information can be sent ).

The sample code is as follows:

Reference content is as follows:

<Html>
<Body>
<Form action = "/example/aspe/demo_aspe_simpleform1.asp" method = "post">
First name:
<Input type = "text" name = "fname" value = "Donald"/>
<Br/>
Last name:
<Input type = "text" name = "lname" value = "Duck"/>
<Br/>
<Input type = "submit" value = "Submit"/>
</Form>
<%
Response. Write (Request. Form)
%>
</Body>
</Html>

How to use information from Forms

This example shows how to use the information retrieved from the form. We use the Form set. The form uses the POST method.

The sample code is as follows:

Reference content is as follows:

<Html>
<Body>
<Form action = "/example/aspe/demo_aspe_simpleform.asp" method = "post">
Your name: <input type = "text" name = "fname" size = "20"/>
<Input type = "submit" value = "submit"/>
</Form>
<%
Dim fname
Fname = Request. Form ("fname ")
If fname <> "" Then
Response. Write ("Hello! "& Fname &"! <Br/> ")
Response. Write ("How is today? ")
End If
%>
</Body>
</Html>

More information from the form

This example shows what information the Form set contains if several input fields use the same name. It will show how to separate these identical names. It also shows how to use the count keyword to count the "name" attribute. This form uses the POST method.

The sample code is as follows:

Reference content is as follows:

<Html>
<Body>
<Form action = "/example/aspe/demo_aspe_form2.asp" method = "post">
First name:
<Input type = "text" name = "name" value = "Donald"/>
<Br/>
Last name:
<Input type = "text" name = "name" value = "Duck"/>
<Br/>
<Input type = "submit" value = "Submit"/>
</Form>
<Hr/>
<P> information from the preceding form: </p>
<%
If Request. Form ("name") <> "Then
Response. Write ("<p> ")
Response. Write ("name =" & Request. Form ("name "))
Response. Write ("</p> <p> ")
Response. Write ("Number of name attributes :")
Response. Write (Request. Form ("name"). Count)
Response. Write ("</p> <p> ")
Response. Write ("First name =" & Request. Form ("name") (1 ))
Response. Write ("</p> <p> ")
Response. Write ("Last name =" & Request. Form ("name") (2 ))
Response. Write ("</p> ")
End if
%>
</Body>
</Html>

Form with single-choice button

This example shows how to use the Form set to interact with users through the single-choice button. This form uses the POST method.

The sample code is as follows:

Reference content is as follows:

<Html>
<%
Dim cars
Cars = Request. Form ("cars ")
%>
<Body>
<Form action = "/example/aspe/demo_aspe_radiob.asp" method = "post">
<P> select your favorite car: </p>
<Input type = "radio" name = "cars"
<% If cars = "Volvo" then Response. Write ("checked") %>
Value = "Volvo"> Volvo </input>
<Br/>
<Input type = "radio" name = "cars"
<% If cars = "Saab" then Response. Write ("checked") %>
Value = "Saab"> Saab </input>
<Br/>
<Input type = "radio" name = "cars"
<% If cars = "BMW" then Response. Write ("checked") %>
Value = "BMW"> BMW </input>
<Br/>
<Input type = "submit" value = "submit"/>
</Form>
<%
If cars <> "" then
Response. Write ("<p> your favorite car is" & cars & "</p> ")
End if
%>
</Body>
</Html>

Form with check button

This example shows how to use the Form set to interact with users through the check button. This form uses the POST method.

The sample code is as follows:

Reference content is as follows:

<Html>
<Body>
<%
Fruits = Request. Form ("fruits ")
%>
<Form action = "/example/aspe/demo_aspe_checkboxes.asp" method = "post">
<P> what fruits do you like: </p>
<Input type = "checkbox" name = "fruits" value = "Apples"
<% If instr (fruits, "Apple") then Response. Write ("checked") %>
Apple
<Br>
<Input type = "checkbox" name = "fruits" value = "Oranges"
<% If instr (fruits, "Oranges") then Response. Write ("checked") %>
Orange
<Br>
<Input type = "checkbox" name = "fruits" value = "Bananas"
<% If instr (fruits, "Banana") then Response. Write ("checked") %>
Banana
<Br>
<Input type = "submit" value = "submit">
</Form>
<%
If fruits <> "" then %>
<P> you like: <% Response. Write (fruits) %> </p>
<% End if
%>
</Body>
</Html>

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.