Specifying a form’s action and other properties
The most important part of a form is not visible to users: it is the form’s action attribute, which specifies the URL of the form handler—the script or program on the Web server to which the form data is passed and which acts on the form data.
In all, each form has five attributes that you may need to specify values for, listed below. Only action must be specified; the other four are optional.
Action
The URL of the form handler. This is the only required attribute. If you do not specify an action, nothing will happen when a user clicks the submit button.
Name
The name of the form. This is only important if you plan to refer to the form in a script. Unlike the names of form controls, the name of the form itself is not sent to the form handler.
Target
The window or frame in which the document returned by the form handler will open. The default value is _self, meaning the response document will open in the same window or frame as the document containing the form. By changing the target, you can have the response document open in a new window, a specific named window, or a specific frame. The target types you can specify are the same as those for hyperlinks. (For more information about targets, see “Setting a link’s target window or frame“.)
The method of sending the form data to the form handler. There are two possible values: GET and POST.
If the method is set to GET, the browser will send the form data by appending it to the URL of the form handler; for example, “http://www.namo.com/search.php?area=support&query=WebEditor”. If the method is set to POST, the browser will send the form data as an HTTP POST request.
GET is the default method. The main advantage of the GET method is that, since the form data is included in the form handler’s URL, users can bookmark the URL to make it easier to send the same request to the form handler in the future. For example, the user could bookmark the search URL in the paragraph above; each time the user uses the bookmark, the search engine would respond to the same query. However, the GET method is limited in that it does not support non-ASCII form data, and the amount of form data that it can send is limited by the maximum URL length supported by the user’s browser. The POST method does not have these limitations, so you should use it whenever users might enter non-ASCII characters (such as Chinese ideograms) in the form, or if the form data might be larger than 100 characters. You should also select POST if the form includes a file browser control.
Encoding type
The content type used to encode the form data when it is sent to the server. The default value is “application/x-www-form-urlencoded”. Generally, you should not change this unless the form includes a file browser control, in which case set the encoding type to “multipart/form-data” and also set the method to POST.
If you enter a mailto link such as “mailto:bob@namo.com” as the action and set the method to POST, most modern browsers will send the form data to the e-mail address in the link. This can be a convenient way to view sample output from a form for testing purposes.
If you are designing a form that does not send information to a server but instead provides data for a client-side script, you do not need to specify a value for the action attribute.
To specify a form’s action and other properties
- Right-click anywhere on the form (within the dashed outline) and then click Form Properties.
- In the Action box, enter the URL of the form handler.
- (optional) Specify any other properties as desired:
- In the Form name box, edit or replace the default name assigned by Namo WebEditor.
- In the Target box, enter the name of the response document’s target window or frame; or click the triangle and select from a list of special targets.
- Click the Method box and select the desired transmission method for the form data. (If you do not specify a method, GET will be used.)
- In the Encoding type box, enter an alternative encoding type for the form data only if necessary. If the form includes a file browser control, enter “multipart/form-data”. In most other cases, you should leave this box blank.
- Click OK.
Changing a form’s style properties
You can apply various style properties to a form as a whole. For instance, you can change its background color, apply a background image, change its alignment on the page, and so forth. To modify a form’s style properties, do this:
- Right-click anywhere on the form (within the dashed outline) and then click Form Properties.
- Click the Style button and then click:
- Character, to change character-related properties, such as font
- Paragraph, to change paragraph-level properties, such as text alignment, line height, and so forth
- Borders & Background, to change the form’s borders, margins, padding, and background color or image.
For more information about using style properties, see the following topics:
- Setting character-related properties
- Setting paragraph alignment, indentation, and line height
- Setting margins, padding, and borders
- Setting background colors and images
Note that any style properties you apply to a form are applied only to the form itself; they are not “inherited” by the form controls within it. To change the appearance of the form controls, you need to edit their style properties individually.