Sunday, June 14, 2015

Forms

Forms


HTML Forms

Forms let us build interactive Web pages that collect information from a user.There are different types of form objects that we can place on our form, including text fields, radio buttons, check boxes, menus (list boxes), and buttons. Basic form elements that are commonly supported by the major Web browsers include the following.

  • <form>
  • <input>
  • <select>
  • <textarea>
The <form> element defines an HTML form.HTML forms contain form elements.Form elements are different types of input elements, checkboxes, radio buttons, submit buttons, and more.The <input> element is the most important form element.The <input> element has many variations, depending on the type attribute. <input type="text"> defines a one-line input field for text input.


Form Processing Basics

When deciding which controls to use, consider the information that you want to collect, use the following progression of controls.

  • Start by finding out whether you can collect pieces of information using check boxes and radio buttons, because they are the quickest and easiest methods of input for the user, requiring only a click of the mouse.
  • Look for a place where you can use a list, which is also easy to use. But try to make the list as short as possible.
  • Then use text fields to collect short text input.
  • Finally, include text areas only if visitors need to give longer responses using their own words.
In general, radio buttons, check boxes, and select lists are all better choices for accepting input than text areas are. If you can provide choices and let users choose from them, do so.To process a form, you must include a button for the user to submit the information that was entered into the form. When someone clicks the Submit button, all of the information that he or she has filled in is sent, in a standard format, to an Internet address that you specify in the form itself. You then have a special forms-processing program at that address that was coded to process that information on the server.

Tag/Attribute Description action="..." Specifies the file, usually a program on the HTTP server that will process the output from the form method="..." Tells the browser how to send the data to the server, with either the POST or GET method. The end result is the same, and the distinction is how the information is provided to the server, either through the URL or through a form object. The action = and method = attributes depend on the server-side program that processes the form.The documentation that came with your form - processing script or with your Web server hosting account will tell you what to use whether POST or GET is the value for the method attribute.
The POST method is almost always used because it instructs the browser to send the form entry results as part of the document header, hiding the data being passed. The GET method is the default value for the method attribute, and is the method used if the method attribute is not specified in the form's opening tag. The GET method appends the data to the end of a URL to pass the data to the server. The GET method is much less secure, but using GET does have some advantages.


Form Controls

Controls are the things that we use to collect user data. They consist of text boxes, buttons, check boxes, and radio buttons, and we will use them to collect and display data.

  • Radio buttons give visitors an opportunity to choose one, and only one, item
  • Check boxes allow visitors to select one item, no items, or several items from a list.
  • Select lists are lists from which the visitor can choose one or more items.
  • Text fields are for short text input, such as names, search terms, or e-mail addresses.

No comments:

Post a Comment