You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Derrick Koes <De...@skillsoft.com> on 2005/04/11 19:56:27 UTC

Html:cancel question

I have a function to disable buttons onsubmit because I don't want the user to keep clicking, especially for long running actions.  However, this seems to interfere when the button is an html:cancel, which is a type of submit.  It seems to ignore the correct behavior of cancelling and attempts to do a validated submit.  What do I need to do to disable buttons AND get cancel to work properly?

function disable(form)
{
    var buttons = form.getElementsByTagName("input");
    for (i = 0; i < buttons.length; i++) {
        if (buttons[i].type == "button" || buttons[i].type == "reset" || buttons[i].type == "submit") {
            buttons[i].disabled = true;
        }
    }
    return true;
}

Thanks,
Derrick

Re: Html:cancel question

Posted by Rick Reumann <st...@reumann.net>.
Rather than try to handle all of this on the client side with 
javascript, it might be better and easier to just use the Token approach 
to handle duplicate submits. I believe there was an email just today 
about this. You can disable the button but the user can still just hit 
enter again and you'll end up with a duplicate submission (using the 
token concept this won't be a problem).


Derrick Koes wrote the following on 4/11/2005 1:56 PM:
> I have a function to disable buttons onsubmit because I don't want the user to keep clicking, especially for long running actions.  However, this seems to interfere when the button is an html:cancel, which is a type of submit.  It seems to ignore the correct behavior of cancelling and attempts to do a validated submit.  What do I need to do to disable buttons AND get cancel to work properly?
> 
> function disable(form)
> {
>     var buttons = form.getElementsByTagName("input");
>     for (i = 0; i < buttons.length; i++) {
>         if (buttons[i].type == "button" || buttons[i].type == "reset" || buttons[i].type == "submit") {
>             buttons[i].disabled = true;
>         }
>     }
>     return true;
> }
> 
> Thanks,
> Derrick


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org