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
Zabi MohammedZabi Mohammed 

creation of multiple Records with an overwritten save button

Hi all,

  I am fasing one problem with Visualforce page Custom Button when i click the custom button multiple times save function is calling multiple times and records are crating multiple times. please help me on this.


Thanks,
 Zabi
surasura
try this . this will diable button on submit
<apex:outputpanel>
   <script>
              function disableOnSubmit(input) {
              setTimeout('disableAfterTimeout(\'' + input.id + '\');', 50);
              }
              function disableAfterTimeout(id) {
              var toDisable = document.getElementById( id );
              toDisable.disabled = 'disabled';
        // Use the Salesforce CSS style to make the button appear disabled
              toDisable.className = 'btnDisabled';
              toDisable.value = "Saving..."
              }
  </script>
  <apex:commandbutton  onclick="disableOnSubmit(this);" action="{!YourAction}" >
  </apex:outputpanel>
sandeep sankhlasandeep sankhla
HI Zabi,

To avod this you can simply show the Loading Symbol which is standard loading symbol..so once user will click he will see the loading symbol and till that time button will be automatically disable and he will not be able to click again..

Its good to show loading symbol , so user will come to know it is porcessing ..

You can refer below code for the same..
 
<apex:actionstatus id="loading" startText="Requesting...">
     <apex:facet name="start">
     <div id="salesforceSource_blurybackground" style="position:absolute; left:1px; top:1px; width:100%; height:100%; text-align:center; vertical-align: middle; background-color: #dcdcdc; opacity:0.7;filter:alpha(opacity=60)"></div>
     <div id="ManageMembersViewport_loading" class="waitingSearchDiv" style="width: 100%; height: 80%; display: ''; ">
      <div style="width: 144px;vertical-align: middle;" class="waitingHolder">
      <table align="center" valign="top" style="width: 100%; height: 30%">
      <tr align="center" valign="top" style="width: 100%; height: 30%">
       <td valign="top"><img src="/img/loading.gif"/><span class="waitingDescription"><b>Loading...</b></span></td>
      </tr>
      </table>
      </div>
     </div>
     <div id="ManageMembersViewport_loading" class="waitingSearchDiv" style="width: 100%; height: 100%; display: ''; "/>
     <script>document.getElementById('ManageMembersViewport_loading').height = window.innerHeight * (3/4);</script>
     </apex:facet>
     <apex:facet name="stop"></apex:facet>
     </apex:actionstatus>




status = "loading"
syntax to use where we want loadding symbol.

Please check with this and let me know if it helps you..

Thanks,
Sandeep