[thelist] JS: test which submit button was clicked.

James Aylard evolt at pixelwright.com
Fri Jun 4 12:12:08 CDT 2004


Tom Dell'Aringa wrote:
> --- Tab Alleman <Tab.Alleman at MetroGuide.com> wrote:
>
>> <form name="FormName" onSubmit="TestRejection('FormName');"
>> action="SomeScript.asp" method="post">
>> <input type="submit" name="WhatToDo" value="Approve">
>> <input type="submit" name="WhatToDo" value="Reject">
>> </form>
>
> The problem is you can't have two submit buttons with the same name.

    Not true.

> In any event, you are going about it the wrong way - two submit
> buttons in not the way to go.
>
> Have a radio button set that has your "approve / reject" choice. Test
> the radio group instead.

    It appears that Tab may be working on a web-based application, and not a
simple web site. Things that may not make sense in a web site sometimes do
make sense in a web application.
    Your alternative to Tab's approach is probably more "correct" from an
HTML standpoint, but IMO it is less intuitive for the user than simply
clicking one of two buttons as he is doing. I would concur with apathetic
about setting a custom property, so long as you also create a means to reset
the value if the form submission is halted by the onsubmit event handler.

James Aylard



More information about the thelist mailing list