• vir
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I want to hide and display two sections based on a user input to a checkbox. In my page I have two sections called section1 and section2. I want to display only section1 when user checks the check box. And display only section2 when user unchecks check box. This works only for section1.

 

<apex:page controller="Sample" >
  <apex:form >  
      <apex:pageBlock id="trainersBlock">
          <apex:inputCheckbox id="isEmp" value="{!isChecked}" >
              <apex:actionsupport event="onclick" rerender="SampleView" />
          </apex:inputCheckbox>
          
          <apex:outputPanel id="SampleView">
              <apex:pageBlockSection rendered="{!isChecked}">
                  <apex:pageblockSectionItem >
                  <apex:outputlabel value="Section 1"/>
                  </apex:pageblockSectionItem>                           
              </apex:pageBlockSection>
              <apex:pageBlockSection rendered="{!isChecked} == false">
                  <apex:pageblockSectionItem >
                  <apex:outputlabel value="Section 2"/>  
                  </apex:pageblockSectionItem>                        
              </apex:pageBlockSection>
          </apex:outputPanel>
       </apex:pageBlock>
  </apex:form>
</apex:page>

 Controller:

public class Sample {

    public String isChecked { get; set; }
}

 

  • July 02, 2011
  • Like
  • 0

I want to hide and display two sections based on a user input to a checkbox. In my page I have two sections called section1 and section2. I want to display only section1 when user checks the check box. And display only section2 when user unchecks check box. This works only for section1.

 

<apex:page controller="Sample" >
  <apex:form >  
      <apex:pageBlock id="trainersBlock">
          <apex:inputCheckbox id="isEmp" value="{!isChecked}" >
              <apex:actionsupport event="onclick" rerender="SampleView" />
          </apex:inputCheckbox>
          
          <apex:outputPanel id="SampleView">
              <apex:pageBlockSection rendered="{!isChecked}">
                  <apex:pageblockSectionItem >
                  <apex:outputlabel value="Section 1"/>
                  </apex:pageblockSectionItem>                           
              </apex:pageBlockSection>
              <apex:pageBlockSection rendered="{!isChecked} == false">
                  <apex:pageblockSectionItem >
                  <apex:outputlabel value="Section 2"/>  
                  </apex:pageblockSectionItem>                        
              </apex:pageBlockSection>
          </apex:outputPanel>
       </apex:pageBlock>
  </apex:form>
</apex:page>

 Controller:

public class Sample {

    public String isChecked { get; set; }
}

 

  • July 02, 2011
  • Like
  • 0