How can I iterate through all forms in a document using javascript?
A:
Hi
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.
Yo Momma
2010-01-27 11:32:10
Whats with the down vote?
Yo Momma
2010-01-27 11:57:50
Obviously because your answer is less elegant then pulse .. I didn't give you vote down btw
c0mrade
2010-01-27 12:30:11
I didn't vote, but note that the "name" attribute has little use on a form, so you'll seldom see it. One would find the uniqueness and addressability of "id" to be more useful, but neither affect the form's functionality.
Anonymous
2010-01-27 12:30:38
Thanks for the input guys, much appreciated
Yo Momma
2010-01-28 05:41:22