Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Object form Property

  • Difficulty Level : Basic
  • Last Updated : 18 Apr, 2019

The DOM Object form Property in HTML DOM is used to set or return the value of the form attribute of an <object> element. The form attribute is used to specify the one or more forms the <object> will contain.

Syntax:

  • It returns the form property.
    objObject.form
  • It is used to set the form property:
    objObject.form = form_id

Property Values: It contains the value i.e form_id that specifies the number of <form> element that an Object contains.

Return Value It returns a string value which represents the one or more form element that belongs to an Object.

Example: This Example returns a form Property.






<!DOCTYPE html>
<html>
  
<body>
    <center>
  
        <object id="myobject" 
                width="400" 
                height="100"
                name="myGeeks"
                form="myGeeks"
                data=
        </object>
        
        <h2>DOM Object form Property</h2>
        <form id="myGeeks">
            <label>Name</label>
            <input type="text">
        </form>
  
        <button onclick="Geeks()">
            Click it
        </button>
  
        <p id="gfg"
           style="color:green;
                  font-size:25px;">
      </p>
    </center>
    <script>
        function Geeks() {
  
            // Accessing Object element. 
            var x =
                document.getElementById(
                    "myobject").form.id;
  
            document.getElementById(
                "gfg").innerHTML = x;
        }
    </script>
  
</body>
  
</html>

Output:

Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM Object form Property are listed below:

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer
  • Opera

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :