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>