<html>
<body>
<p>Click the button to display the id of the form the hidden input element belongs to.</p>
<form id="myForm">
<input type="hidden" id="myInput">
</form>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myInput").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>