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

Dynamically render page sections based on checkbox values
Hello Evryone,
I am trying to render two sections based on two checkbox values. If Export is TRUE then show Sample1 and in Import is TRUE then show Sample 2.
VF Page:
Controller:
I am trying to render two sections based on two checkbox values. If Export is TRUE then show Sample1 and in Import is TRUE then show Sample 2.
VF Page:
<apex:page standardcontroller="Opportunity" tabStyle="Opportunity" extensions="OppExt"> <apex:form > <apex:pageBlock title="Opportunity Edit"> <apex:pageBlockButtons > <apex:commandButton action="{!getcontinue}" value="continue"/> <apex:commandButton action="{!Cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageBlockSection id="block" title="Service Type Field Information" columns="2" > <apex:inputField value="{!Opportunity.Export_ck__c}"> <apex:actionsupport event="onclick" rerender="Sample1" status="AjaxStatus1"/> </apex:inputField> <apex:inputField value="{!Opportunity.Import_ck__c}"> <apex:actionsupport event="onclick" rerender="Sample2" status="AjaxStatus2"/> </apex:inputField> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Information" columns="2"> <apex:outputField title="Opportunity Owner" value="{!Opportunity.OwnerId}"/> <apex:inputField required="true" value="{!Opportunity.Type}"/> <apex:inputField value="{!Opportunity.Name}"/> <apex:inputField value="{!Opportunity.LeadSource}"/> <apex:inputField value="{!Opportunity.AccountId}"/> <apex:inputField value="{!Opportunity.CloseDate}"/> <apex:inputField required="true" value="{!Opportunity.Priority__c}"/> <apex:inputField required="true" value="{!Opportunity.Lead_Source_Details_del__c}"/> <apex:inputField value="{!Opportunity.Contact__c}"/> <apex:inputField value="{!Opportunity.Mobile__c}"/> </apex:pageBlockSection> <apex:outputpanel id="Sample1"> <apex:actionStatus id="AjaxStatus1"> <apex:facet name="stop"> <apex:pageBlockSection title="Additional Information" columns="2" rendered="{!IF(Opportunity.Export_ck__c == true, true, false)}"> <apex:inputField required="true" value="{!Opportunity.NextStep}"/> <apex:inputField required="true" value="{!Opportunity.Description}" /> <apex:inputField required="true" value="{!Opportunity.Followup_DateTime__c}"/> </apex:pageBlockSection> </apex:facet> </apex:actionStatus> </apex:outputpanel> <apex:outputpanel id="Sample2"> <apex:actionStatus id="AjaxStatus2"> <apex:facet name="stop"> <apex:pageBlockSection title="Other Information" columns="2" rendered="{!IF(Opportunity.Import_ck__c == true, true, false)}"> <apex:inputField required="false" value="{!Opportunity.Probability}" /> <apex:inputField value="{!Opportunity.Test_Month_Closed_Today_s_Month__c}"/> </apex:pageBlockSection> </apex:facet> </apex:actionStatus> </apex:outputpanel> </apex:pageBlock> </apex:form> </apex:page>
Controller:
public with sharing class OppExt { Public Opportunity opp {get;set;} Public Boolean Export_ck {get;set;} Public Boolean Import_ck {get;set;} Private ApexPages.StandardController sController; public OppExt(ApexPages.StandardController controller) { this.opp=(Opportunity)Controller.getRecord(); sController=controller; } Id DomesticRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Domestic').getRecordTypeId(); public PageReference getcontinue() { sController.save(); PageReference pr = new PageReference('/006/e?retURL=%2F006%2Fo&RecordType='+DomesticRecordTypeId+'&ent=Opportunity'); pr.setRedirect(true); return pr; } }
This Simple code may help you to achieve your goal.All the best.
Regards
Nitesh