Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript-HTML - how to iterate through all the forms on a page?

How can I iterate through all forms in a document using javascript?

like image 738
anonymous Avatar asked Jan 27 '10 11:01

anonymous


2 Answers

You can use

document.forms collection

See forms Collection

like image 155
rahul Avatar answered Oct 14 '22 16:10

rahul


The code below will go through an html document, get all forms and do a pop-up alert of the names of each form.

var formsCollection = document.getElementsByTagName("form");
for(var i=0;i<formsCollection.length;i++)
{
   alert(formsCollection[i].name);
}

This is just a start to see if you are getting the reult you require. Thereafter, remove the alert and continue to do what you need to.

like image 23
Yo Momma Avatar answered Oct 14 '22 14:10

Yo Momma