Previous Example-|-Next Example-|-Return to Chapter Listing

Example 10.6:
Getting the forms Array's length Property


Here's the first form in the document (it doesn't do anything):
Here's the second form. The buttons use different methods of referring to the form when getting the length property:



This is the script we used in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function FormLengthArray() { alert("The form has " + document.forms[1].length + " elements.") } function FormLengthName() { alert("The form has " + document.secondForm.length + " elements.") } //--> </script> Later in the page we have these buttons (in the second form): <FORM NAME="secondForm"> <INPUT TYPE="button" NAME="But1" value="Display the form length (the number of elements in the form) using the forms array" onclick="FormLengthArray()"><B> <INPUT TYPE="button" NAME="But2" value="Display the length using the form name" onclick="FormLengthName()"> </FORM>
Previous Example-|-Next Example-|-Return to Chapter Listing