Reputation: 262
I've been trying to submit a form through mootools (1.4.5) on FF 14. The form does not contain an input named submit (which is often the problem). What I want is onchange in a select to submit the form. After half an hour the code below was my first attempt that got it working. objSelect is a select object that is contained within the form that I need to submit.
$(''+objSelect.getParent('form').get('id')).submit();
.
What the reason that the code below doesn't work as well?
// Without the explicit cast to string (''+); doesn't work
$(objSelect.getParent('form').get('id')).submit();
nor
// Most obvious way; doesn't work
objSelect.getParent('form').submit();
Upvotes: 2
Views: 283
Reputation: 26165
you can't have child nodes with reserved names that get exported via old DOM level API - see here how forms are being represented: http://www.quirksmode.org/js/forms.html#access
So basically - at an element level, if you have:
form.foo
and form.bar
will reference these element on the form element object.
the problem in your case is:
.submit
and .reset
method)
now form.submit
stops referencing the submit method and starts referencing the input element.
you still submit this form by doing either:
new Element("form").submit.call(this.getParent("form"));
basically you create a new form element with a clean submit method. that returns an object and you call the method with the other "dirty" form as context.
this is just the same as doing
Array.prototype.slice.call(arguments)
Upvotes: 1