In Chapter 18, "Adding Interactivity-Forms the Easy Way," you learned how to generate a form using the FrontPage Form Page Wizard. The Form Wizard created the form by prompting you with a series of questions. The form fields and the layout were handled automatically.
What if you want to create your own layout, add additional form fields, or edit the content of the forms that you designed with the wizard? This chapter shows you how to do that. You learn how to work with the elements that make up a form.
Every form has some basic elements within it. Form fields are the areas where users enter data. Each form field has a name so that the data can be arranged by category. Every form has a button that users press to submit information to your site. Finally, every form also has a form handler-a set of instructions that tells your server how to process the information that users submit.
When you ask users a question or need input from them, they enter their responses in a form field. For example, the form fields shown in Figure 19.1 are textboxes and radio buttons. You insert a form field on your page with the Insert | Form Field command.
Figure 19.1 :Users enter data on your form with form fields.
Whenever you insert a form field on a page, you automatically create a form. If you have the Show/Hide button on the Standard toolbar enabled, the form fields are surrounded by a dashed box. This shows you the area of the page where the form appears.
Each form field is assigned a name through its respective Properties box, as shown in Figure 19.2. The name of the field is passed first to the form handler and then to you through the use of name/value pairs-that is, the name you assign to the form field and the value the user enters.
Unless you place a button on your page, the form cannot do anything. A form must contain, at a minimum, a button that the user presses to submit the information to you. Most forms include a second button that enables the user to reset or clear the data from the form fields already completed. These buttons are shown in Figure 19.3.
After you design a form, you need to assign a form handler to it. You do that with the Form Properties dialog box, shown in Figure 19.4. The form handler resides on your Web server. It accepts the data that the user enters on the form and processes it in some way. Then it passes the results on to you.
Figure 19.4:Every form requires a form handler. It is assigned in the Form Properties dialog box.
HTML enables you to place several different types of form fields on a page. There are fields for a single line of text or for multiple lines or paragraphs. You also can use check- boxes, radio buttons, drop-down menus, and pushbuttons. You can even use an image as a pushbutton. Each type of form field requests an input from the user.
Use a single-line text input form field when you expect a brief response from the user or if you need to request a password. The maximum number of characters allowed in a single-line text input field is 256. Figure 19.5 shows a textbox and the settings entered for it in the Text Box Properties dialog box.
Figure 19.5:Textboxes are used for brief text responses.
To place a one-line textbox on your form:
TIP |
If you want to align your forms similarly to how the Form Page Wizard does, format the line on which you want to insert the form field as a formatted paragraph. Use the arrow keys to move back and forth through the alignment; use the backspace and space keys to alter the spacing of the labels and the form fields. |
You can change any property for the textbox after it appears on your page by selecting the textbox and choosing Edit | Properties, or by pressing Alt+Enter.
Use the Insert | Form Field | Scrolling Text Box command to insert a multiline, or paragraph, textbox field on your form. Figure 19.6 shows a scrolling textbox.
Figure 19.6:Scrolling textboxes are used for lengthy text responses.
To place a scrolling textbox on your form,
You can change any property for the scrolling textbox after it appears on your page by selecting the scrolling textbox and choosing Edit | Properties, or by pressing Alt+Enter.
Use checkboxes to give the user a Boolean choice, such as Yes/No or True/False. Check- boxes also are used to present a multiple list of items from which the user can select single or multiple choices. Figure 19.7 shows several checkboxes.
Figure 19.7:Checkboxes allow the user to select or
deselect a choice in your form.
TIP |
Checkboxes are often arranged in groups. You can place the first one on your form and copy it and its label to your clipboard. Then you can paste in the additional checkboxes and edit the properties of the copies. This saves you a few extra steps, and it helps you visualize the layout. |
To place a checkbox on your form:
You can change any property for the checkbox after it appears on your page by selecting the checkbox and choosing Edit | Properties, or by pressing Alt+Enter.
Radio buttons are similar to checkboxes in that they are used to give the user a Boolean choice. Typically, radio buttons are arranged in a group and are assigned a group name. The user selects only one option, as in Figure 19.8. The group name and the value assigned to each selected button are sent to the form handler after the user submits the form.
To place radio buttons on your form:
TIP |
Inserting radio buttons is one time when copying the first button and pasting copies to your form really helps. You can keep the group name consistent if you enter the properties for the first radio button and copy additional radio buttons on the page. |
You can change any property for the radio button after it appears on your page by selecting the radio button and choosing Edit | Properties, or by pressing Alt+Enter.
Menus are used to present the user with a list of defined choices. Items are displayed in either a drop-down list or a scrolling list. You can configure a drop-down menu list to permit single or multiple selections. Figure 19.9 shows a single-selection drop-down list.
To place a drop-down menu on your form:
For each item that you want to add in the drop-down menu, complete these steps:
After you enter your menu list items, complete the menu list as follows:
Based on the Height and Allow Multiple Settings values, the drop-down
menu can appear in several ways. Table 19.1 shows how most browsers
display a drop-down menu based on your choices.
Height | Multiple | appearance |
1 | No | Displays as a drop-down list |
1 | Yes | Displays as a scrollable list with half-height arrows |
2 or above | No | Displays as a scrollable list with half-height arrows |
2 or above | Yes | Displays as a scrollable list with half-height arrows (may be difficult to use unless the list height is sufficient to display all or most items in the drop-down menu list) |
Pushbutton fields are used to submit or reset the data that the user enters in form fields. You can insert more than one pushbutton on a form, as Figure 19.10 shows.
Figure 19.10:Pushbuttons are used to submit or clear the data from the form.
FrontPage provides two types of pushbuttons that can be used with the FrontPage form handling bots: a Submit button and a Reset button. You can write custom CGI scripts to add additional buttons to your form and to assign other names and values to them.
To place a pushbutton on your form:
You can change any property for the pushbutton after it appears on your page by selecting the pushbutton and choosing Edit | Properties, or by pressing Alt+Enter.
If you write custom form handlers, you can use image form fields to submit data entered on your forms. The button shown beneath the standard form buttons in Figure 19.11 is an image form field. When a user submits a form by clicking an image field, FrontPage passes the coordinates from the image's coordinate system to the form handler. The bots do not use this coordinate information, so you must create a custom form handler to process the coordinates.
Figure 19.11:You can use images as buttons in a form field if you use custom CGI scripts.
To place an image form field on your form:
Use hidden form fields to pass information from one form to another. For example, the Product Data Sheet that you created with the Corporate Presence Web (see Chapter 6 "Real-Life Examples") contains an information request form. This information request form uses a hidden form field to pass the name of the product to the results file and to the confirmation form that is sent to the user.
You can use hidden form fields in other ways as well. Suppose, for example, that your first form has a question such as How long ago did you read this book? and that the user responds 16 days. A custom CGI script looks at that value and determines that the user read the book within the last month. The CGI script returns a hidden form field from the first form, shown in Figure 19.12, to the user in a form on another page that says You read your favorite book in the last 1 month.
Figure 19.12:Hidden form fields are used to pass information from one form to another.
To create a hidden form field:
To modify a hidden form field:
To delete a hidden form field:
You already learned how to create forms quickly by using the Form Page Wizard. In this chapter, you learned how to add your own form fields and edit their properties. There now remains one major step in designing your forms, which you learn about in the next chapter.
In this chapter, you learned about the various form fields that you can use. You learned how to insert them in your Web pages and how to configure each type of field. You also learned some tips to help you align your form fields just as the Form Page Wizard does.
In the next chapter, you learn how to assign a form handler to your forms and what the runtime bots do. You can find related information in the following chapters:
Q: | What about extended attributes? All the Form Field Properties dialog boxes have Extended Attributes buttons on them. |
A: | FrontPage has all the attributes for each form field built in. The Extended Attributes button is there in case you need them in the future. |
Q: | Can I design a form from scratch and not use the templates or the Form Page Wizard? |
A: | Yes, but the Form Page Wizard streamlines the task by taking care of the layout. Using it is a much quicker way of designing a form. |
Q: | I don't like the way my form looks. What is the easiest way to delete it and start over again? |
A: | There are a couple of ways in which you can delete a form from a page. For example, delete every object on the form and use the Backspace or Delete key to delete the form. To delete a form field, use the Delete or Backspace key. Alternatively, position the cursor in the upper left corner of the form, where it turns into a selection pointer. Double-click to select the entire form and cut the page to the clipboard, or use the Del key to delete the form from the page. |