Use the forms collection to access each of three Form objects and show the value of their name properties in a message box.
<!DOCTYPE html> <html lang="en"> <body> <form action="" name="form1"> <p> This is inside form1. </p> </form> <form action="" name="form2"> <p> This is inside form2 </p> </form> <form action="" name="form3"> <p> This is inside form3 </p> </form> /*from www. j ava 2 s . co m*/ <p id="demo"></p> <script> let numberForms = document.forms.length; for (let index = 0; index < numberForms; index++) { document.getElementById("demo").innerHTML +=" "+ document.forms[index].name; } </script> </body> </html>