Using the Forms Array : Form Object « Form « JavaScript Tutorial






<html>
    <head>
    <title> Using the forms array to access a form element</title>
    </head>
    <body>
    <script language = "JavaScript">
    <!--
    function showFormName(){
         var name = document.forms[0].name;
         alert("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>








10.2.Form Object
10.2.1.Form
10.2.2.Using the Forms Array
10.2.3.Form.action
10.2.4.Form.elements
10.2.5.Form.elements.length
10.2.6.form.encoding
10.2.7.Form.handleEvent()
10.2.8.Form.length
10.2.9.Form.method
10.2.10.Form.name
10.2.11.Form.onReset
10.2.12.Form.onSubmit
10.2.13.Form.reset()
10.2.14.Form.submit()
10.2.15.Form.target