Form.elements : Form Object « Form « JavaScript Tutorial






The elements property represents the elements array, which is used to access each element within a form.

The order of the form elements in the elements array is the order in which they appear in the HTML source.

<html>
    <head>
    <title> Using the form elements property</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    function getName(){
         var textName = document.form1.elements[0].name;
         alert("The textbox name is: " + textName);
    }
    -->
    </script>
    <form name="form1">
    This is a blank input textbox. Click on the button below to get the name of the textbox.
    <br>
    <input type="text" name="textbox1" size=25>
    <br><br>
    <input type="button" value="Get Name" onClick = getName()>
    </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