Javascript Form How to - Access the Form object in which the password box resides








Question

We would like to know how to access the Form object in which the password box resides.

Answer


<!-- w w w.  ja v  a2  s  .  c  om-->
<html>
<body>
    <form name="form1">
    <input type="PASSWORD" Name="pass" size=10>
    <br>
    <input type="BUTTON" value="Show Formname" onClick=console.log(document.form1.pass.form.name)>
    </form>
</body>
</html>

The code above is rendered as follows: