Object form Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object


The form property sets or gets the form attribute of an <object> element, where the <object> element is from.

Set the form property with the following Values

Value Description
form_id Sets the <form> element the <object> element belongs to.

Return Value

A String, representing one or more forms the object belongs to

The following code shows how to get the id of the form the <object> element belongs to:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form id="form1">
  An Example Form: <input type="text" name="exampleform">
</form>/*from   w  w w.j a va2s . c  om*/

<object id="myObject" data="helloworld.swf" width="200" height="200" name="obj1" form="form1"></object>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myObject").form.id;
    document.getElementById("demo").innerHTML = x;


Related Tutorials