首页javascriptformJavascript Form - 如何获取与密码框相关联的类型属性...

Javascript Form - 如何获取与密码框相关联的类型属性...

我们想知道如何获取与密码框相关联的类型属性。...


    <html>
    <body>
    <script language = "JavaScript">
    function showFormName(){
         var name = document.forms[0].name;
         console.log("The name of the form is: " + name);
    }
    </script>
    <form name="form1">
    This text box belongs to a form.
    <input type="text" name="street">
    <br><br>
    Click on the button to get the name of the form.
    <br>
    <input type="button" value="Get Form name" onClick='showFormName()'>
    </form>
    <form name="form2">
    This is the second form in the document. It contains a FileUpload object.
    <input type="file" name="uploadbox" size="25">
    </form>
    </body>
    </html>