Beginning HTML, XHTML, CSS and JavaScript - Code Examples

Back to main book index

Chapter 5: Forms

Here are the examples for Chapter 5, which looks at how to create forms to collect data from users.

ch05_eg01.htmlA simple search form with a text input and submit button

Form Controls

ch05_eg02.htmlSingle line text input control using the <input> element
ch05_eg03.htmlPassword input control using the <input> element
ch05_eg04.htmlMulti-line text input control using the <textarea> element
ch05_eg05.htmlCreating buttons using the <input> element
ch05_eg06.htmlCreating buttons using the <button> element
ch05_eg07.htmlCreating checkboxes using the <input> element
ch05_eg08.htmlCreating radio buttons using the <input> element
ch05_eg09.htmlCreating a drop down select box using the <select> element
ch05_eg10.htmlCreating scrolling select box using the <select> element and the size attribute
ch05_eg11.htmlSelect boxes with the multiple attribute
ch05_eg12.htmlGrouping options with the <optgroup> element
ch05_eg13.htmlGrouping options with a disabled <option> element
ch05_eg14.htmlCreating a file upload box using the <input> element
ch05_eg15.htmlCreating a hidden form control using the <input> element
Try it outA contact form

Labelling and Organising Forms

ch05_eg16.htmlUsing the <label> Element
ch05_eg17.htmlOrganising Form Controls with <fieldset> and <legend> Elements
ch05_eg18.htmlAn Example of Tabbing Order using the tabindex attribute
ch05_eg19.htmlUsing the accesskey Attribute
Try It OutExtending the contact form

Exercises

Exercise 1An feedback form
Exercise 2A voting form