The use of HTML forms

Source: Internet
Author: User

1. Forms tab

<form> tags are used to create HTML forms for user input.

Grammar:

<form action= "server program url" method= "Get|post" enctype= "MIME Info" target= "How documents are Displayed" > Form detail Settings </form>

Attribute Explanation:

Action: Specifies the format in which the submission form is processed.

Method: Indicates the HTTP way to submit the form. Possible values are: Post: Record, register, automatic check at computer startup (submit to background), get: Get command, get file (submit current page, unsafe)

Enctype: Indicates the form of Internet media used to submit the form to the server (when the method value is "post").

Target: Specifies the location where the submitted results document is displayed: _blank: In a new, nameless browser window, the specified document is transferred; _self: In the same frame that specifies the element of the target; _parent: Document

into the immediate parent frameset box of the current box; _top: Puts the document into the top-most browser window.

The code is as follows:

<action= "login.php"  method= "POST"  target= "_ Blank ">... </ form >

2. Form fields

The INPUT element has all type types as follows: (Details see the "HTML5 form for all types of forms")

Other forms other elements of the form:

1). TextArea (multiline text box)

The code is as follows:

<name= "Content"  rows= "5"  cols= "  ></textarea>

Property Description:

Name: The names of the elements.

Rows: Specifies the height of the text box.

COLS: Specifies the width of the text box.

2). Select (Drop-down box)

The code is as follows:

<formAction="#"Method= "POST">    <h4>Pull-down effect:</h4>Area:<Selectname= "area">        <optionvalue= "1">Beijing</option>        <optionvalue= "2"selected>Guangzhou</option>        <optionvalue= "3">Shanghai</option>        <optionvalue= "4">Heilongjiang</option>    </Select>    <h4>Multi-Select effect:</h4>Area:<Selectname= "area"size= "3"multiple>       <optionvalue= "1">Beijing</option>        <optionvalue= "2"selected>Guangzhou</option>        <optionvalue= "3">Shanghai</option>        <optionvalue= "4">Heilongjiang</option>    </Select><BR>Here size= "3" indicates that the selection box shows three rows

Property Description:

Size Defines the number of rows in a drop-down selection box
Name Define the name of the drop-down selection box
Multiple Indicates that you can select multiple options, and if you do not set this property, you can only select single
Value Define the value of the selection
Selected Indicates that this item is already selected by default
Disabled Whether to disable

Group label <opgrounp>:

The code is as follows:

<formAction="#"Method= "POST">Area:<Selectname= "area"size=""3 Multiple>        <Optgrouplabel= "Domestic"<option Value= "1">Beijing</option>            <optionvalue= "2"selected>Guangzhou</option>            <optionvalue= "3">Shanghai</option>            <optionvalue= "4">Heilongjiang</option>        </Optgroup>        <Optgrouplabel= "foreign"<option Value= "1">New york</option>            <optionvalue= "2"selected>Paris</option>            <optionvalue= "3">Moscow</option>            <optionvalue= "4">Melbourne</option>        </Optgroup>    </Select>

Property Description:

Label Property: Defines the name of the combination of options.

3). Other labels

<fieldset> tag function is the combination of elements in the form.

<legend> label defines a caption for the FIELDSET Element (caption)

The code is as follows:

<fieldset>    <legend>Registered</legend>    <formname= "form"Action="#"Method= "POST">User name:<inputtype= "text"name= "username">Password:<inputtype= "Password"name= "pas">        <inputtype= "Submit"name= "Sub"value= "Submit">    </form></fieldset>

The <label> tag defines the callout (tag) for the INPUT element. It works by associating an entry or an option with its label text.

The For property of the <label> tag should be the same as the ID property of the related element

The code is as follows:

<inputtype= "Radio"name= "Sex"value= "1"ID= "Man"><label for= "Man">Man</label><inputtype= "Radio"name= "Sex"value= "0"ID= "Woman"><label for= "Woman">Woman</label>

(for the time being here ...) )

The use of HTML forms

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.