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
Rohith Kumar 98Rohith Kumar 98 

How to render a pageBlockSection on click of commandButton?

I want to render a particular pageBlockSection when a commandButton is clicked.

Command Button:
<apex:commandButton value="Add Labor" id="AddLabour" style="margin-left: 90%"/>

Page Block Section:
<apex:pageBlockSection title="Search Labours" collapsible="false" columns="3">
                <apex:outputLabel value="Component" for="SearchLaborKey"/>
                <apex:inputText id="SearchLaborKey" style="width: 100%"/>
                <apex:commandButton value="Find Labor Cost"
                style="margin-left: 70%; background:#0170b7; color:white"/>
            </apex:pageBlockSection>

Please help, thanks in advance.
mukesh guptamukesh gupta
Hi Rohit,

Add in visualforce page
<apex:commandButton value="Add Labor" reRender="sectionsPanel" action="{!addSection}"  id="AddLabour" style="margin-left: 90%"/>
<apex:outputPanel id="sectionsPanel">
		<apex:pageBlockSection title="Search Labours" collapsible="false" columns="3">
                <apex:outputLabel value="Component" for="SearchLaborKey"/>
                <apex:inputText id="SearchLaborKey" style="width: 100%"/>
                <apex:commandButton value="Find Labor Cost"
                style="margin-left: 70%; background:#0170b7; color:white"/>
            </apex:pageBlockSection>
</apex:outputPanel>


Add in Apex class:
public PageReference addSection() {

                return null;
    }

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh