HTML form (Forms)
HTML forms (Form) is an important part of HTML, mainly for the collection and submission of user input information.
Cite a simple example, allows users to input a name of the HTML form (Form). Sample code is as follows:
<form Action="http://www.nt22.com/asdocs/html_tutorials/yourname.php" method="get" />
Please enter your name:
<input Type="text" name="yourname" />
<input Type="submit" value="Submit" />
</ Form>
Learning HTML form (Form) is the master key to the three main points:
- Controls form (Form Controls)
- Action
- Method
First, control form (Form Controls), through HTML form of control, users can input text messages, or choose from the options, and to do the operation. For example, the above examples, input type = "text" is a form controls, indicated that a single input box.
Users fill in the form of information is always necessary procedures for handling, in the form of action to deal with the specified form of information documents. For example, the above examples http://www.nt22.com/asdocs/html_tutorials/yourname.php.
As for the method that the form sent information. There are two value method: get and post. Get through the controls will form the name / value information is encoded, sent through the URL (you can see in the address bar). The post will form the content sent through http, you do not see in the address column of the form to submit information. When it get used, and when used post? This is generally judged, and if only for the acquisition and display data, get used; is involved in the preservation of data and update, then proposed that post.
HTML forms (Form) is commonly used controls (Controls)
HTML forms (Form) is commonly used controls are:
| Controls form (Form Contros) | Note |
| Input type = "text" | Single text input box |
| Input type = "submit" | Will form (Form), the information submitted to the action in the form of documents at |
| Input type = "checkbox" | Box |
| Input type = "radio" | Single box |
| Select | The drop-down box |
| TextArea | Lines of text input box |
| Input type = "password" | Password input box (using the text input *) |
Controls form (Form Control): single text input box (input type = "text")
Single text input box allows users to input some brief one-way information, such as user names. Examples are as follows:
<input Type="text" name="yourname" />
Controls form (Form Control): box (input type = "checkbox")
Box allows users to a group of options, select more than one. Sample code:
<input Type="checkbox" name="fruit" value ="apple" /> Apple <br>
<input Type="checkbox" name="fruit" value ="orange" /> orange <br>
<input Type="checkbox" name="fruit" value ="mango" /> mango <br>
Checked that with the default option has been chosen.
<input Type="checkbox" name="fruit" value ="orange" checked> orange <br>
Controls form (Form Control): single box (input type = "radio")
The use of single box, enabling users in a group, one can choose only one option. Sample code:
<input Type="radio" name="fruit" value = "Apple" /> Apple <br>
<input Type="radio" name="fruit" value = "Orange" /> orange <br>
<input Type="radio" name="fruit" value = "Mango" /> mango <br>
Checked that with the default option has been chosen.
<input Type="radio" name="fruit" value = "Orange" checked> orange <br>
Controls form (Form Control): drop-down box (select)
The drop-down box (Select) can be used for radio, and can also be used as a check. Radio examples are as follows:
<select Name="fruit" />
<option Value="apple" /> Apple
<option Value="orange" /> orange
<option Value="mango" /> mango
</ Select>
If a check, plus muiltiple can. Ctrl users to achieve more with the election. Examples:
<select Name="fruit" multiple>
Users also can be used to change the size attribute the drop-down box (Select) size.
Controls form (Form Control): multi-line input box (textarea)
Multi-line input box (textarea) mainly used for the importation of a longer text messages. Examples are as follows:
<textarea Name="yoursuggest" cols ="50" rows = "3" /> </ textarea>
Cols that textarea which the width of rows that textarea height.
Controls form (Form Control): password input box (input type = "password")
Password input box (input type = "password") mainly for the importation of certain confidential information, such as passwords. Because when the user input that is not imported, but black spots symbols. . Examples are as follows:
<input Type="password" name="yourpw" />
Controls form (Form Control): Submission (input type = "submit")
Through the submission (input type = submit) can form (Form), the information submitted to the action in the form at the document. Examples are as follows:
<input Type="submit" value="submit" />
Controls form (Form Control): picture submitted (input type = "image")
Input type = image equivalent input type = submit, the difference is that the input type = image of a picture as a form submit button, the picture src attributes that path.
<Input type = "image" src = "images / icons / go.gif"
Alt = "submit" NAME = "imgsubmit" />
