Search code examples
javascriptvisualforce

In visualforce page onclicking 1st button activate 2nd button


In my visualforce page there is 2 buttons(Insert and Continue). When Continue button is clicked then Insert button should be shown in page otherwise Insert button should be hidden.

<apex:pageBlockButtons Id="buttonContainer">
<apex:commandButton value="Insert" rerender="mainForm"rendered= 
{!showInsertButton}" onClick="javascript:fnInsertCompany();return false;" />
<apex:commandButton action="{!continue}" value="Continue" 
</apex:pageBlockButtons>

Solution

  • You have used rendered attribute to your Insert button. You can easily render this button in a conditional logic.

    In Continue button, the action is continue i.e. you have a method called continue() in your controller.

    So, globally make the showInsertButton = false AND in continue() method, make the

    showInsertButton = true  
    

    Thats all.