I have a function I want to attach to all forms passing the form itself as an argument. When I submit the form, I see that the function gets called, but the argument is either null or some other element in the DOM.
This method is already called within a class, so this
is probably the wrong thing to pass, but forms[i]
did not work either. What do I pass in place of the ?
, or is there a better way?
var forms=this.content.getElementsByTagName('form');
for(var i=0;i<forms.length;++i){
// TODO: handle if there is already an onsubmit() function
forms[i].onsubmit=function(){SubmitForm(?);}
}