Prev

Forms

Remember: Forms are used to get user input.
Many web sites have a need for users to be able to enter information as well as view it. One way this is possible is using HTML forms. An html form is an invisible container tag, like the <body> tag. You put form elements to allow the user to enter information; some of these include checkboxes, text fields, and radio buttons.

Once the user has entered information, there is usually a button, called a submit button that the user clicks, which submits (sends) the information to a page on the web server. This page is usually not going to be a simple HTML page, but rather a dynamic page that doesn't always look the same. You will see an example of this in action in the asynchronous chat activity.

The <form> tag

Remember: The form tag requires the method and action attributes.

Remember: The action attribute for the <form> tag specifies the URL the form information is sent to.
The <form> tag doesn't show up on your page, but rather is an invisible container tag that holds the form elements. It tells the browser where the html form begins and ends. The <form> tag has some required attributes that tell the browser how to handle the form when it is submitted. These include the action attribute and the method attribute. The value of the action attribute is a URL (absolute or relative) telling the browser where the form information should be sent.

Form methods

Remember: A form can be sent using either the GET or the POST method.

Tip: The POST method is better for lots of information or for private information.
The method attribute describes the way the browser sends the information. There are two methods that can be used, the "GET" method and the "POST" method. When the browser uses the GET method all of the information in the form is attached to the end of the action URL as a query string. This is more useful for small amounts of information. When the browser uses the POST method, the information in the form is sent separately from the action URL as data. This is better for sending lots of information or information that is more sensitive, like credit card information. We will be using the POST method in our asynchronous chat activity.

Prev