Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <form id="myForm"> Name: <input type="text" id="myText" value="Mickey"> </form> <p>Click the "Try it" button to display the id of the form the text field belongs to.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myText").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html> <form autocomplete="off" style="margin:0px;display:none;"> <input type="hidden" name="code" id="code"> <input type="hidden" id="bt" name="bt"> </form>
Result: