function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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

Vi5hVi5h
Hello,

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


// add this before your apex:form
<script>
    
    function processCancellation(btn){
        btn.disabled = true;
        btn.value = "Please wait..";
        processCancel1();  // actionfunction
    }
    
    </script>
//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 
processCancel1

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

Ta
Vish