|
Form ObjectBy using the form you have at your disposal information about the elements in a form and their values. You can alter many of these of these values as needed. A separate instance of the form object is created for each form in a document. Objects within a FORM can be referred to by a numeric index or be referred to by name. <FORM
There are two Methods available with the FORM Object:
Properties of the Form Object
With this Property, you can ascertain the ACTION specified in the FORM definition. For instance, in a form defined with the following:
the ACTION property has a value of "/cgi-bin/test.pl".
The encoding property reflects the MIME type, which is used to encode the data submitted from a FORM to the server. This means that the property reflects the ENCTYPE attribute of the <FORM> tag, and you can set the encoding of a FORM by changing the value of this property. The default value is "application/x-www-form-urlencoded" which is sufficient for almost all purposes. For example, a value "text/plain" is convenient when the FORM is being submitted by email to mailto:URL This is useful when you want to upload a file to be processed by a CGI script on the server. For information go to http://www.ics.uci.edu/pub/ietf/html/rfc1867.txt.
A read/write string that specifies the technique for submitting the form. It should have the value "GET" or "POST". Initially specified by the METHOD attribute.
This property provides the programmer with the name specified in the form definition. In the form defined with the
the NAME Property has a value of "myForm".
The target property is similar to the ACTION and NAME Properties and makes the content of the TARGET attribute available to the programmer. A read/write string that specifies the name of the frame or window in which the results of submitting a form should be displayed. Initially specified by the TARGET attribute. The special name "_top", "_parent", "_self", and "_blank" are also supported for the TARGET Property and the TARGET attribute (more of this will be covered in Week 8). In the FORM definition
the TARGET Property has a value of "thatFrame". It is possible to dynamically change the target of a form by assigning a new value to the TARGET Property. In the preceding example, the target could be changed from thatFrame to anotherFrame by using document.myForm.target="anotherFrame". NOTE: TARGET can only be assigned a string literal. It cannot be assigned an expression or a variable. |