 item on the form is given a different name. The name attribute is added as follows:
<input type="text" name="username">
Which names this textbox 'username'. As with many tags involved with HTML forms, this is an invisible change, and is only really of use once you start processing forms. If you are submitting your form using GET, though, the input's name will be shown in the URL of the page (it is also sent with the data if you use POST, but this is invisible), for example:
A third attribute which can be used with your textbox is value. This allows you to set an initial value for your textbox, which can be changed by the user, for example if I had a textbox to take in an e-mail address, I could set the inital value to 'email@example.com' by the following code:
<input type="text" name="email" value="firstname.lastname@example.org">
There are a few more attributes which can be used with textboxes, but they are not necessary for basic forms, so these will be covered in the next part.
More HTML In Forms
Although it is probably obvious, I will just mention that all other HTML tags are available to you inside your <form> tags. It is important to remember, for example, to label all your input elements, so that the user knows what to enter in them. You can use all other types of HTML formatting as well as text, though, and often the use of tables can help set out an HTML form in a better way.
Once you have got the user to enter some data into a form, however basic it may be, you will need some way for them to send it on to the next page. This is where buttons come in. There are two basic buttons available to you in HTML, submit and reset. Submit is the most commonly used. Basically, when you put in a submit button, a button will appear on the page which, when clicked, tells the browser to send the form data to the URL which you defined in the action part of the form tag, using the method you supplied. The most basic submit button is added using the following code:
There is an optional attribute of the submit button, though, which allows you to customize it slightly. This is the value attribute, which is used in exactly the same way as for a textbox, although in this case it simply changes the text on the button's face.
<input type="Submit" value="Sign Up">
You can have as many submit buttons in a single form as you like (for example many websites provide an 'I Agree' button at the top and bottom of a long page of terms and conditions, but all submit buttons in a single form will do the same thing.
The second button you can add to your form is a reset button. All this does when clicked is to reset the form to its initial state (usually clearing all values but, in the case of the value attribute being set for an input option, it will also restore the initial values you set). This is added to a form using:
Like a submit button, reset can also have its text changed using the value attribute.
In this part you have learned the basic format of an HTML form, including how the form is structured with it, how to submit and reset the form and how to get basic inputs. HTML offers a huge number of other input options, though, which will be covered in the next part.
1999 - 2019 FreeWebmasterHelp.com