Zero-based HTML Tutorial (7): One of the basics of HTML forms

Source: Internet
Author: User
Tags html form

one, the HTML form

The form is responsible for the user input data collection function in the webpage, uses the <form> label to define a form. The data in the middle of the <form>...</form>form label will be uploaded to the server for processing

second, the form of the most important element--<input> elements

There are many types of input essential type attributes, let's explain each one.

1.text Property, <input type= "text" >

Text is used for textual input, for example, in the body of the page to add:

<form>

Search: <input type= "text" name= "Search" >

</form>

You can implement the appearance of the search box. Of course, this only has the appearance does not have the function ...

2. Radio button input, <input type= "Radio" >

Radio is used to define radio buttons , so that the user can select a feature in multiple options that is implemented through radio. For example, add in the main page:

<form>

<p>1 plus 1 equals a few? </p>

<p><input type= "Radio" name= "Answer1" value= "1" >1<input type= "Radio" name= "Answer2" value= "2" >2 </p>

</form>

You can implement a simple selection function. Where the Name property is used when the Type property is a radio, optional operation can only select one item in the Input tab with the same name value to achieve the radio function. Value is used to upload real values , the value of the input selected when submitting the form is uploaded, interacting with the database, but this is something.

3. Submission of the form, <input type= "Submit" >

The type attribute's submit is the most commonly used method of submitting a form, giving the type a value value that can be displayed directly on the Submit button. In addition, the submit submission of the form needs to be opened to the form

Label actin property to specify the action of the form when it is uploaded, and if omitting the action attribute does not write, the action defaults to the current page. Combine what you've just learned to write a form with a submit button:

<form action= "form.php" >

<p> account: <input type= "text" name= "USNA" ></p>

<p> Password: <input type= "password" name= "password" ></p>

<p>1 plus 1 equals a few? </p>

<p><input type= "Radio" name= "Answer" value= "A1" Checked>1<input type= "Radio" name= "Answer" value= "A2" >2</p>

<input type= "Submit" value= "submitted" >

</form>

The type password here is used to define the password input, and the input text will be indicated by the asterisk "*", which is the same as text. In this tutorial we learned the basics of HTML forms, and the next one will be expanded to create a complex form.

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.