Form.elements.length : Form Object : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Form Object »

 

Form.elements.length








The elements.length property specifies the number of items in the elements array.

Each item in the array refers to an object in the HTML form.












<html>
    <head>
    <title> Using the elements.length property of the Form object</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    function getNum(){
         var numOfElements = document.form1.elements.length;
         alert("The number of elements in this document are:" + numOfElements);
    }
    -->
    </script>
    <form name="form1">
    Dummy text box:
    <input type="text" name="textbox1" size="25">
    <br>
    <input type="button" value="Dummy Button">
    <input type="text" size="20" name="Sample">
    <br><br>
    Click on the button to get the number of elements in this form.
    <input type="button" value="Get Elements" onClick='getNum()'>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Form Object