You need to sign in to do that
Don't have an account?

Render two sections based on a user input to a check box
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; } }
Please use this
VFP
I have tested it , works fine, I hope it will help you.
All Answers
Try:
Please use this
VFP
I have tested it , works fine, I hope it will help you.
Thanks for borth replies. Mainly the error was in:
As in the accepted solution, that should be like:
Thanks again!