Introduction to Forms
File Management:
- Create a new folder in your web folder called "forms"
- Open this link in a new tab.
- View the source of the page.
- Copy all of the source code into a blank Notepad.
- Save your notepad as "form_examples.html" in your "forms" folder.
- Close the original source and tab.
- View the HTML file you saved in a Web browser.
Examine the HTML:
- Notice the form element. The "action" attribute tells the form where to submit to.
- Notice the fieldset and legend elements. The fieldset creates a group and the legend provides a description in the line around the group.
- Notice the input elements and label elements. Each input element is one possible choice or entry in the form, and the labels make it clear what content goes with each input.
- Notice the "type" attribute on the input elements. This determines what kind of input it is. You will do a whole worksheet on input types next week.
- Notice the select and option elements. They create dropdown and multiple selection boxes. Here they are used to make a dropdown box.
- Notice the last input: it is of type "submit" and that is how the form knows when you submit it. When you click on this button is sends the form contents to the action page that is specified in the form element.
Submit the Form
- View the form in a Web browser.
- Test the form by filling it out and submitting it.
- Read the results. This action page will simply read back any input names and the values you filled out.
- For example, if you changed the three radio button names from "optGroup" to "radioOptGroup" and then saved, refreshed, and filled out the form again, you would see that change reflected in the results.
- Do that and test it.