HTML and CSS Reference
In-Depth Information
Exercises
1. What's a BOM? What's a DOM? What is the Legacy DOM and why is it used
with forms?
2. How does the name attribute differ from the id attribute of an input device?
3. Create an HTML document that contains two forms. One form consists of a text
field, the other a text area. Name the forms and the input devices. Use Java-
Script to print out the names and values in the forms.
4. Add a button to the last example. If the user clicks it, display the form content
in another window.
5. Create two text fields. In one text field, the user will enter his or her birth
month and day. Write a JavaScript program that will print the number of days
until his or her birthday in the second text field.
6. Write a JavaScript function that will finish the story in Example 11.20.
7. Write a multiple-choice quiz. It has five questions and the user can only select
one answer. After the user selects an answer, alert him or her if he or she is
wrong, and show the user the correct answer in a separate textbox field.
8. Change Example 11.36 so that a confirmation box will appear, asking the user
to confirm his or her vacation choices. The vacation choices will be listed in a
popup window.
9. Create a form that uses a text input type. Ask the user to type his or her name in
uppercase letters. The submit button will be an image. Validate that the form is
not empty and that the user typed his or her name in only uppercase letters.
Send the form to a server program if it is valid.
10. Create a form with radio buttons representing different colors. Use the id attri-
bute for each radio button. In a JavaScript program, the getElementsById() will
return a reference to the radio button that was selected. Change the background
color to the color that was selected.
Search WWH ::




Custom Search