Javascript Reference - HTML DOM Input Hidden form Property








The form property gets the form containing the hidden input field.

Browser Support

form Yes Yes Yes Yes Yes

Syntax

var v = hiddenObject.form

Return Value

A reference to the form element containing the hidden input field. If the hidden input field is not in a form, null is returned.





Example

The following code shows how to get the id of the form containing the <input type="hidden"> element.


<!DOCTYPE html>
<html>
<body>
<form id="myForm">
  <input type="hidden" id="myInput">
</form><!--  ww  w  .  j ava2 s  .com-->

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

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

<script>
function myFunction() {
    var x = document.getElementById("myInput").form.id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: