You can collect all the elements of a form into an Object, through which you can iterate to do whatever you want to.
var oForm = document.forms;
//holds the reference to the first form in the documents,
//you can access the other forms by changing
var iLength = oForm.elements.length; //get the number of form elements
//if you want to find the no. of text boxes in a form, here's how you do it.
var oElements = oForm.elements; //get all the elements of the for to oElements
var iTextCount = 0; //to store the no. of text boxes
if(oElements[i].type == "text")
iTextCount += 1;
//Now iTextCount stores the no. of text boxes in the form.
//You can do a lot of things with forms in this way.
Hope this was helpful to you. Drop a query if you wanna know anything else.