The Form object

Form elements cannot be placed in an HTML document haphazardly; they must be placed inside a form. To create a form in HTML, simply use the <form> tag, and, optionally, include the name parameter to identify it, the submission method ('get' or 'post'), and the action to be taken on submission.

For example, to create a form using the post method of submission to a Perl script located at http://apcmag.com/cgi-bin/perlScript.pl, you could use the following code:

<form name="theForm" method="post" action="http://apcmag.com/cgi-bin/perlScript.pl">
(form elements, etc.)
</form>

Like a frame, a form inside an HTML page is made into an object for use with JavaScript. The Form object is a property of the window object, so you can refer to form elements in your scripts using the following syntax:

window.theForm.element

Finally, because an HTML page can contain multiple forms, each form is contained in an array, and is also available as a property of the Window object. Therefore, assuming that the form in the previous example was the first form on a page, the form element could also have been referenced using the following alternative syntax:

window.forms[0].element