Sometimes there are situations in which we have two or more forms in a single page and accessing these forms is a tedious task by there names. So JavaScript provides form arrays elements which are accessed as :
<!DOCTYPE html> <html> <head> <title>form arrays HTML</title> <script type="text/javascript"> function form12() { document.forms[0][0].value ="first"; // accessing form1's first element document.forms[1][0].value ="Second"; // accessing form2's first element } </script> </head> <body onload="form12()"> <form method="post" name="form1"> <input type="text" name="dummyfield"/> <input type="text" name="dummyfield2"/> <input type="submit"> </form> <form method="post" name="form2"> <input type="text" name="dummyfield"/> <input type="text" name="dummyfield2"/> <input type="submit"> </form> </body> </html>