You are here: Reference > JavaScript > client-side > HTML DOM > properties > form (input, select, textarea, ...)

form property (input, select, textarea, ...)

Browser support:
Returns a reference to the form element in which the object is placed.

Syntax:

object.form;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Reference to the container form element. If the object is not in a form, returns null.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the form property:
<head>
    <script type="text/javascript">
        function GetForm (button) {
            alert ("The id of the container form: " + button.form.id);
        }
    </script>
</head>
<body>
    <form id="myForm">
        <div>
            <input type="button" value="Get the ID of the container form!" onclick="GetForm (this);"/>
        </div>
    </form>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content