Mega Code Archive

 
Categories / JavaScript DHTML / Form Control
 

Button to display the names of all the elements in a form

<html> <head> <script type="text/javascript"> function showFormElements(theForm){     str="Form Elements: "     for (i=0; i<theForm.length; i++)         str+=" \n " + theForm.elements[i].name         alert(str)     } </script> </head> <body> <form>     First name: <input type="text" name="fname" size="20">     <br>     Last name: <input type="text" name="lname" size="20">     <br>     <br>     <input type="button" name="button1" value="Display name of form elements"             onClick="showFormElements(this.form)"> </form> </body> </html>