I would like to submit a standard html form using the XMLHttpRequest
object. As far as I can tell there is no easy way to do this. What I
have to do is:
1 Register an event handler on the forms submit event
2 In this handler I have to:
2.1 Prevent the default action so that the form does not submit in
the current window
2.2 text/x-www-form-urlencode all the form element name value pairs
following the rules at:
http://www.w3.org/TR/html4/interact/...#submit-format
2.3 Build an XMLHttpRequest to the form action uri and then send all
the encoded elements
All this is fine, except that at:
http://www.w3.org/TR/html4/interact/...#submit-format
the standard specifies that:
"If a form contains more than one submit button, only the activated
submit button is successful" and hence only this submit buttons name
value pair has to be submitted.
There does not appear to be any standard way to determine which input
submit element was active during the submit! However, the form.submit()
method knows which element was active so there must be a way (without
registering event handlers on all the input submit buttons).
IE has the unstandard document.activeElement property, is there a
standard property somewhere? Is there an equivalent to this in gecko?