- Understanding Forms
- Creating a Form
- Inserting Form Objects
- Modifying Text Fields and Text Areas
- Modifying Radio Buttons and Check Boxes
- Modifying Lists and Menus
- Modifying Buttons
- Inserting an Image Button
- Making Form Objects Dynamic
- Using Tables to Control Forms
- Validating Forms
- Creating and Editing a Jump Menu
- Viewing Example Code for Forms
As mentioned in the previous section, forms are all about the collection and eventual processing of information. Considering the information-based society that we live and work in, without forms the entire world would probably fall apart in a matter of days. Well, maybe that’s a bit exaggerated; however, forms collect information, information drives our lives, and Dreamweaver makes the creation of those forms a virtual snap.
It’s important to understand that although Dreamweaver will make the overall creation of a form easy (buttons, check boxes, input fields, etc), it does not include the backend tools that make the form functional. For that you will need to install a form handler on your server. In many cases someone in the IT department performs this function. Understand that until the form handler is installed, your visitors will not be able to send you any data; no matter how many times they click the Submit button.
While the scope of the book is not to teach you how to write form handler code, there are many sites that offer free form-handler scripts. These sites typically provide scripts for collecting simple and predictable form data; for more complex scripts the services of an engineer might be required.
Forms can be populated with any number of elements. For example, you could create a simple bio form that asks for information such as name, address, phone number, sex, age, social security number, etc. Because of all this information, it’s a good idea to sketch out the general look and feel of the form on a piece of paper, and then use that as a visual guide to the creation of the form in Dreamweaver. When you create an interactive field, Dreamweaver inserts the code necessary to display the field in the browser.
Dynamic Form Elements
A dynamic form element is a form object that gets its initial value by the web server where the web site is stored. When a visitor opens a form page in a browser, the dynamic form objects get information directly from the web server before the page appears on the screen. When form objects are dynamic, it makes updating a snap. In order to use dynamic form objects, you need to have a data source set up and available on your web server.
Once the various form elements are ironed out, you can look at the possibility of validating some of the fields. For example, it might be difficult to create a validation for a name field; however, you at least check to see that the field is not blank. In addition, you could check to see if all zip code fields contain five numbers and not alphabetic characters. Options that require specific answers, such as sex (male/female) could be placed as a pop-up with the correct choices, and other options could be designed using check boxes or radio buttons. In most cases, using check boxes allows the user to choose more than one option (check all that apply), and radio button typically allow for a single choice from a group (choose only one). When you choose form validation, Dreamweaver creates a script that instructs the browser how to handle the input.