good evening fellow code bashers:
i know it should be simple, but i’m tired and just want to get it done. this is how i thought it should be done, which is identical to how this fellow did it, BUT numberOfForms comes up ZERO, instead of THREE (that’s how many forms are on the page, all named & id’d). what did i miss?
var numberOfForms = document.getElementsByTagName("form");
console.log("numberOfForms: " + numberOfForms);
for (var i=0; i<numberOfForms.length; i++)
{
document.forms[i].reset;
}
shed some light, plz. then i can punch out and hit the hay.
Try this. You have already got an array with all HTML DOM Form elements. Use
numberOfForms[i].reset()instead of trying to usedocument.forms[n].Actually this is cleaner and more efficient, there is actually no need to traverse the DOM with
document.getElementsByTagName()