18.2. Adding Form ElementsClick inside the first cell in your form's table, and go to the Insert panel. Choose the form element that you want to insert. You have several options, as Table 18-1 shows.
18.2.1. Inserting Text FieldsLooking back at the form sketch in this example, the first item is a text field, so click the Text Field object in the Insert panel, as in Figure 18-7. When you do, the Input Tag Accessibility Options dialog box appears, as Figure 18-8 shows. Figure 18-7. The Text Field object's iconFigure 18-8. Setting the label and accessibility options for the text field
In the Label field, type the label from your form sketch, and under Style, choose the option to attach the label tag using the for attribute. When you're laying out the form in a table, this option works the best. Also supply an access key and the tab index for this field. The tab-index value should be 1 here, because this is the first element in the form.
Click OK, and Dreamweaver adds the text field to the table, as Figure 18-9 shows. Now click the text field itself, and drag it into the table cell next door, as Figure 18-10 shows. Leave the label in its current table cell. Figure 18-9. Dreamweaver adds the text field to the tableFigure 18-10. Drag the text field to the adjacent table cellClick the text field to select it, go to the Property Inspector, and fill out the attributes of this element, as Figure 18-11 shows: Figure 18-11. Setting the attributes of the text field
18.2.2. Inserting Text AreasA text area is a multiline text field. To insert a text area, click the Textarea object on the Insert panel, as Figure 18-12 shows. Dreamweaver opens the Input Tag Accessibility Options dialog box again. Fill out the label and accessibility options for this field, as Figure 18-13 shows. Figure 18-12. The Textarea object's iconFigure 18-13. Setting the accessibility options for the text areaDrag the text area into the adjacent table cell. Then select the text area and fill out the attribute fields in the Property Inspector as in Figure 18-14:
18.2.3. Inserting CheckboxesYou add checkboxes one at a time to your form. Instead of inserting them into the left column of your form table and then moving them to the right, you can insert them directly into the right column. To insert a checkbox, click the Checkbox object on the Insert panel, as Figure 18-15 shows, which gives you the familiar Input Tag Accessibility Options dialog box shown in Figure 18-16. The caption for a checkbox works better when it comes after the form element, so be sure to choose the After option under Position. Click OK to add the checkbox to the document window. Figure 18-15. The Checkbox object's iconFigure 18-16. Positioning the caption after the checkboxNow select the checkbox, and go to the Property Inspector to fill in the attributes as in Figure 18-17:
Figure 18-17. Supplying the attributes for the checkboxTo insert the next checkbox in the table cell, hold down the Shift key and press Enter or Return to insert a line break rather than a new paragraph. This gives you the insertion point that you want. When you finish, your document window looks something like Figure 18-18. Figure 18-18. The checkbox options are separated by line breaks18.2.4. Inserting Radio GroupsUnlike checkboxes, which you add one at a time, you can insert an entire group of radio buttons simultaneously. To do so, choose an insertion point in the right column of your table, and click the Radio Group object in the Insert panel, as Figure 18-19 shows. Dreamweaver opens the Radio Group dialog box, as Figure 18-20 shows. Figure 18-19. The Radio Group object's iconFigure 18-20. Building the group of radio buttons and their attributesIn the Name field, type brief but descriptive name for the radio buttons. All the buttons in the group get the same name. Under Radio Buttons, supply labels and values for all the buttons in the group. The label is the text that appears on screen, while the value is what goes into the form submission when the visitor selects that particular radio button. Use the plus and minus buttons to add and remove radio buttons from the group and use the arrow buttons to rearrange their order. Under Lay Out Using, choose either Line Breaks or Table. Line breaks are easier to modify when you want the radio buttons to sit side by side rather than in a column, but the choice is yours. Click OK, and Dreamweaver adds the radio group to the document window, as Figure 18-21 shows. Figure 18-21. Dreamweaver adds the radio group to the document windowTo remove the line break after the top radio button's label, position the cursor at the end of the line, and press the Delete key to get the result shown in Figure 18-22. Figure 18-22. Without the line break, the radio buttons sit adjacent
Every radio group should have a preselected option, so select the radio button that you want to make the default choice, go to the Property Inspector, and choose Checked as the initial state, as Figure 18-23 shows. Figure 18-23. Setting one of the radio buttons to be preselected18.2.5. Inserting Lists and MenusThe difference between lists and menus is subtle but important. Both are for displaying sets of options. The difference is that a list shows several options at once, which encourages the visitor to make multiple selections, while a menu shows one option at a time, which encourages the visitor to select one option only.
To insert a list or menu, choose an insertion point in the left column of your form table, and click the List/Menu object in the Insert panel, as Figure 18-24 shows. As you probably expect, Dreamweaver calls up the Input Tag Accessibility Attributes dialog box. Fill out the dialog box, as Figure 18-25 shows. Figure 18-24. The List/Menu object's iconFigure 18-25. Supplying the label and accessibility optionsClick OK, and Dreamweaver inserts the form field on the page in menu format. Drag the menu to the adjacent table column. Then select the menu, and go to the Insert panel. Type a brief but descriptive name for the element in the field under List/Menu, and choose the List option if you want this item to appear in list format. To supply the choices for the list or menu, click the List Values button, and the List Values dialog box in Figure 18-26 appears. For each option, type a label, which is the text that appears on screen in the list or menu, and a value, which is the text that the form submits when the visitor chooses this particular item. Add and subtract menu items with the plus and minus buttons, and change the order of the items with the arrow buttons. Figure 18-26. Building the options set for the list or menu
Click OK, and Dreamweaver adds the items to the list or menu. If you're creating a menu, then in the Initially Selected field on the Property Inspector, choose the item that the browser should preselect. Normally, this is the first item in the menu, as Figure 18-27 shows. Figure 18-27. Choosing an option to be preselected in the menu18.2.6. Inserting ButtonsButtons come in three types, but the first two are the most relevant to the current discussion. These are the Submit button and the Reset button. A Submit button sends off the fields of the form and a Reset button restores them to their default values.
To insert a button, click the Button object on the Insert panel, as Figure 18-28 shows, and fill out the Input Tag Accessibility Attributes dialog box as in Figure 18-29. You don't need to specify a separate text label, because you'll add the label directly to the button once you've created it. Figure 18-28. The Button object's iconFigure 18-29. You don't have to give a separate text label for the button
Click OK to insert the button. Now select it in the document window, and then fill out the Property Inspector as Figure 18-30 shows:
Figure 18-30. Supplying the attributes of the buttonYour form should definitely include a Submit button. If it doesn't, the visitor has no way of sending you the form input! A Reset button, on the other hand, is optional. If you want both types, simply insert another button in the table cell. When you're finished, notice that the cell to the right is empty, as in Figure 18-31. There's no reason to keep the right table cell, so you can join the cells of this row. Here's how: Figure 18-31. There's nothing in the table cell to the right of the one with the buttons
Dreamweaver merges the selected cells, as Figure 18-33 shows. Figure 18-33. Dreamweaver merges the table cells |