+ Start a Discussion
bozotheclownbozotheclown 

Preventing Multi Clicks While Waiting for the NEXT Page

Hello.  I am struggling to identify a way to prevent multiple records being created by clicking a commandbutton multiple times (often due to a slow internet connection).  I know there are a few ways to accomplish this if the commandbutton is not set up to take the user to another page (simply by making the button disappear briefly, etc).

However, my problem is that I have a commandbutton that inserts a record and then takes the user to another page.  It seems the tricks for making a button disappear briefly (such as actionstatus) do not work when the commandbutton is taking the user to a different page.

In other words, I am trying to figure out a way for a user to click a commandbutton...the button will disappear...and the user will then be taken to the next page.

Any suggestions?

Thanks in advance.
Best Answer chosen by bozotheclown
Eric_SalesForceEric_SalesForce
We use a javascript function like this to avoid duplication:

<script>
    var isClicked = false;
    function checkDoubleSubmit(obj){
        if (isClicked) {
         
            return false;
        }else {
            isClicked = true;
            obj.className = 'btnDisabled';//only shows the button as disabled.
        }
    }
</script>

In your button have an onclick="return checkDoubleSubmit(this);"

All Answers

Eric_SalesForceEric_SalesForce
We use a javascript function like this to avoid duplication:

<script>
    var isClicked = false;
    function checkDoubleSubmit(obj){
        if (isClicked) {
         
            return false;
        }else {
            isClicked = true;
            obj.className = 'btnDisabled';//only shows the button as disabled.
        }
    }
</script>

In your button have an onclick="return checkDoubleSubmit(this);"
This was selected as the best answer
bozotheclownbozotheclown
Thanks.  Much appreciated.