Access form in document.forms without knowing index or name:
Posted: Thu Dec 10, 2009 7:18 pm
Suppose I have a form that has no name and no id and I wish to access all of its elements by calling documents.form[].elements[].
From what I can tell, I would have to use this.form so that my function would know fromm which object it is being called.
The problem now however: I am not calling that function from the form, but rather from another function that accepts the 'this' as a parameter.
IE:
So, how in anotherFunction would I know which is my index to use in document.forms[]? Or, is it even possible?
From what I can tell, I would have to use this.form so that my function would know fromm which object it is being called.
The problem now however: I am not calling that function from the form, but rather from another function that accepts the 'this' as a parameter.
IE:
Code: Select all
function anotherFunction(form, group) {
var buttons = document.forms[form].elements[group];
}
function someFunction(form) {
anotherFunction(form, "group")
}
<form onsubmit="return someFunction(this);" action="..." method="get">...other stuff in here...</form>