Creating a form
Submit and Reset buttons
Since we have completed our assessment of the various form fields, we need a way to submit or reset this information. Add the following code:
<tr> <td colspan="2" align="center"><br> <input type="submit" name="submit" value="submit"> <input type="reset" name="reset" value="reset"> </td> </tr>
First, we want our buttons to span the form and table; we set the last table cell to span two columns by using colspan with a value of 2. To center our buttons, we add align with a value of center. To provide a bit of vertical separation between the previous form field and the buttons, a break tag is added. Again, you might notice our buttons are created using the same input tag as a text field, radio button or checkbox. What makes an input become a button is specifying the type as either submit or reset. The attribute/values of the input tag are:
Type:
- Specifies the type of input, in this example, submit and reset
Name:
- Specifies the name of our input field, in this example, submit and reset
Value:
- Specifies the value of each button, in this example, submit and reset
More importantly, the value is what enables the form to either submit the information or reset the value of our forms fields to empty values. Save your file and preview the results.
Summary
In this article, you learned how to create a form. You also learned about:
- Attribute/value pairs of form tags
- Various form fields used, which include:
- Text fields
- Drop down (select)
- Text area tags (comments)
- Radio buttons
- Checkboxes
- Submit and reset buttons
Take the knowledge gained here and create any form imaginable!
If you have questions, contact me.