+ Start a Discussion
rakesh ranjanrakesh ranjan 

We have a command button on vf page which calls a webservice. We want to disable the button once it is clicked. Can some one help please


I implemented a similar logic in one of my projects.. here is the code

// add this before your apex:form
    function processCancellation(btn){
        btn.disabled = true;
        btn.value = "Please wait..";
        processCancel1();  // actionfunction
//add this after your apex:form
<apex:actionFunction action="{!processCancellation}" name="processCancel1" />

//use this for the button

<apex:commandButton id="finish" value="Finish" onclick="processCancellation(this);return false;" />

So, onclick of the button the javascript method will be executed processCancellation(this) when the javascript execution completes it calls the action function 

"{!processCancellation}" in the action is the call to your method in apex