Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Using the Forms Array

< html>     <head>     <title> Using the forms array to access a form element</title>     </head>     <body>     <script language = "JavaScript">     <!--     function showFormName(){          var name = document.forms[0].name;          alert("The name of the form is: " + name);     }     -->     </script>     <form name="form1">     This text box belongs to a form.     <input type="text" name="street">     <br><br>     Click on the button to get the name of the form.     <br>     <input type="button" value="Get Form name" onClick='showFormName()'>     </form>     <form name="form2">     This is the second form in the document. It contains a FileUpload object.     <input type="file" name="uploadbox" size="25">     </form>     </body>     </html>