The form
property gets the form containing the hidden input field.
form |
Yes | Yes | Yes | Yes | Yes |
var v = hiddenObject.form
A reference to the form element containing the hidden input field. If the hidden input field is not in a form, null is returned.
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: