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
Venkat Reddy 45Venkat Reddy 45 

hide a block on button click, show the block again after button click

Dear Experts,

        I want to "hide a block on button click, show the block again after button click"

Please help me with code.

Andy BoettcherAndy Boettcher

Once you get through Trailhead and get a good basic understanding of Visualforce and Lightning Components, you can use frameworks like jQuery to accomplish what you speak of here.
Himanshu ParasharHimanshu Parashar

As Andy said yes it will be great if you can go through the Trailhead which will help you to understand basic of visualforce and its component so here I giving you one hint to solve your issue.

There are two attributes in <apex:actionfunction component called action which can call controller side method and  rerendered which can rerender any specific section after call complete. you can use that as starting point for your problem's solution.


Rupal KumarRupal Kumar
Hi ,
 Try this
vf page-
<apex:page controller="TestPage4">
  <apex:form >
      <apex:pageBlock id="block">
          <apex:pageBlockSection title="Section 1" rendered="{!showSection1}">
          <apex:pageBlockSection title="Section 2" rendered="{!showSection2}">
          <apex:pageBlockSection title="Section 3" rendered="{!showSection3}">
      <apex:commandButton action="{!method1}" value="Button1" reRender="block"/>
      <apex:commandButton action="{!method2}" value="Button2" reRender="block"/>
public with sharing class TestPage4 {
    public Boolean showSection1{get;set;}
     public Boolean showSection2{get;set;}
     public Boolean showSection3{get;set;}
     public TestPage4 ()
         showSection1= false;
        showSection2= true;
        showSection3 = true;

    public PageReference method2() {
       showSection1= true;
        showSection2= false;
        showSection3 = true;
        return null;

    public PageReference method1() {
        showSection1= false;
        showSection2= true;
        showSection3 = false;
        return null;



Rupal Kumar
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help u

Please let us know if this will help u