HTML Forms
Chapter 5. HTML Forms
Table of Contents
Objectives .............................................................................................................................................................. 2
5.1
Introduction ................................................................................................................................................ 2
5.1.1
Processing Forms ........................................................................................................................ 2
5.2
Creating Forms .......................................................................................................................................... 3
5.2.1
Starting a Form ............................................................................................................................. 3
5.2.2
Single-line Text Entry .................................................................................................................. 4
5.2.3
Multi-line Text Entry .................................................................................................................... 6
5.2.4
Radio Buttons ............................................................................................................................... 7
5.2.5
Check Boxes ................................................................................................................................. 9
5.2.6
Menu Buttons and Scrolling Lists .............................................................................................. 10
5.2.7
Submit and Reset Buttons .......................................................................................................... 13
5.3
HTML5 form elements ............................................................................................................................ 14
5.3.1
Email address field ..................................................................................................................... 14
5.3.2
Search ......................................................................................................................................... 14
5.3.3
Url .............................................................................................................................................. 15
5.3.4
Autofocus ................................................................................................................................... 15
5.3.5
Dates and Times ......................................................................................................................... 15
5.3.6
Color ........................................................................................................................................... 15
5.3.7
Numbers as Spinboxes ............................................................................................................... 15
5.3.8
Numbers as Sliders ..................................................................................................................... 16
5.4
Using Forms ............................................................................................................................................. 16
5.5
Additional Content and Activities ........................................................................................................... 17
5.5.1
Supplementary information on HTML forms ............................................................................. 17
5.5.2
Additional Activity — Tabular Layout of a Complex Form ...................................................... 17
5.6
Review Questions .................................................................................................................................... 18
5.7
Discussions and Answers ......................................................................................................................... 20
5.7.1
Discussion of Activity 1 ............................................................................................................. 20
5.7.2
Discussion of Activity 2 ............................................................................................................. 20
5.7.3
Discussion of Activity 3 ............................................................................................................. 21
5.7.4
Discussion of Activity 4 ............................................................................................................. 23
5.7.5
Discussion of Activity 5 ............................................................................................................. 25
5.7.6
Discussion of Activity 6 ............................................................................................................. 25
5.7.7
Discussion of Activity 7 ............................................................................................................. 28
5.7.8
Discussion of Activity 9 ............................................................................................................. 29
5.7.9
Discussion of Additional Activity .............................................................................................. 31
5.7.10
Answer to Review Question 1 .................................................................................................... 32
5.7.11
Answer to Review Question 2 .................................................................................................... 33
5.7.12
Answer to Review Question 3 .................................................................................................... 33
5.7.13
Answer to Review Question 4 .................................................................................................... 33
5.7.14
Answer to Review Question 5 .................................................................................................... 33
5.7.15
Answer to Review Question 6 .................................................................................................... 33
5.7.16
Answer to Review Question 7 .................................................................................................... 33
5.7.17
Answer to Review Question 8 .................................................................................................... 33
5.7.18
Answer to Exercise 1 .................................................................................................................. 34
5.7.19
Answer to Exercise 2 .................................................................................................................. 34
5.7.20
Answer to Exercise 3 .................................................................................................................. 34