W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2008

Re: FORM successful submit element?

From: Joćo Eiras <joao.eiras@gmail.com>
Date: Sun, 10 Aug 2008 17:56:37 +0100
To: "DOM mailing list" <www-dom@w3.org>
Message-ID: <op.ufoj0nymjz3wb9@mors>

Hi.
Opera probably gives the info you want because Opera supports WebForms 2,  
and in web forms you can have several submit buttons with different  
actions. It seems the other browsers have this behavior undefined.


On , Garrett Smith <dhtmlkitchen@gmail.com> wrote:

> How to identify the submit button when a form was clicked?
>
> The form below has three elements that can be used to submit the form.
> If the form is submitted, it could be that one of the buttons would be
> the cause, and, in that case, that button should be included in the
> query string.
>
> The browsers seem to have an internal mechanism for determining which
> button is successful. Is the form's successful button exposed in the
> DOM?
>
> <form action="" id="theForm">
>   <input name="text" value="blah">
>
>   <input id="submit" name="submit" value="submit form here"  
> type="submit">
>   <input id="submit2" name="submit2" value="submit form there"  
> type="submit">
>   <input id="submit3" name="submit3" value="submit form elsewhere"
> type="image" alt="[submit elsewhere]" src="missing.null">
> </form>
> <script>
> document.getElementById('theForm').onsubmit = function(e) {
>    alert(e.relatedTarget.type);
> };
> </script>
>
> Opera: "image", et c.
> IE8, FF3, Safari 3: Error
>
> When the form is submitted, how to determine if and which submit input
> was the cause?
>
> Garrett
>
Received on Sunday, 10 August 2008 16:57:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:59 GMT