+ Start a Discussion
Big EarsBig Ears 

Using Checkboxes to dynamically render page sections

Hey guys,

 

I'm trying to have Visualforce render a pagesection dependent on whether or not a checkbox has been selected. I'm getting nowhere fast and was wondering if somebody could help?

<apex:pageblock title="Additional Required Information"> <apex:outputtext value="Is the status for a set period of time, set amount of units, or other?" /> <apex:pageblocksection columns="5"> <apex:pageblocksectionitem > <apex:outputlabel value="Time" for="TimeScope" /> <apex:inputcheckbox value="{!Opportunity.Period_of_Months__c}" id="TimeScope" />

</apex:pageblocksectionitem> <apex:pageblocksectionitem > <apex:outputlabel value="Amount of units" for="UnitScope" /> <apex:outputpanel > <apex:inputcheckbox value="{!Opportunity.Status_Number_of_Units__c}" id="UnitScope"> <apex:actionsupport event="onchange" rerender="ProductUnitsInformation" status="AjaxStatus" /> THIS SECTION SHOULD CAUSE THE SECTION AT THE BOTTOM TO RENDER (OR NOT) </apex:inputcheckbox> </apex:outputpanel> </apex:pageblocksectionitem> <apex:pageblockSectionItem > <apex:outputlabel value="Other" for="OtherScope" /> <apex:inputcheckbox value="{!Opportunity.Status_Other__c}" id="CarbonScope" /> </apex:pageblockSectionItem> <apex:pageblocksectionitem > </apex:pageblocksection>

<apex:pageblocksection> <apex:outputpanel id="ProductUnitsInformation"> THIS IS THE SECTION TO BE RE-RENDERED <apex:actionStatus id="AjaxStatus" startText="Requesting..."> <apex:facet name="stop"> <apex:pageblocksection rendered="{!Opportunity.Status_Number_of_Units__c}"> <apex:pageblocksectionitem > <apex:inputfield value="{!Opportunity.Number_of_Units__c}" /> <apex:inputfield value="{!Opportunity.Unit_Identifier__c}" /> </apex:pageblocksectionitem> </apex:pageblocksection> </apex:facet> </apex:actionStatus> </apex:outputpanel> </apex:pageblock>

 

What I'm trying to make happen is, upon selection of the checkbox (id = UnitScope, with the child apex:actionsupport tag), the apex:outputpanel (id=ProductunitsInformation) should render.

 

Currently, upon selection of the checkbox, the action status does not render, and the screen does not change. I'm sure I'm just being naive, but I've not had a great deal of success with the event handlers and AJAX updates.

 

If anybody could point me in the right direction, I'd be very thankful.

 

Andy

Best Answer chosen by Admin (Salesforce Developers) 
JeremyKraybillJeremyKraybill

Hi Andy,

 

from memory I believe your actionSupport event needs to be onclick, not onchange.

 

HTH

 

Jeremy Kraybill

Austin, TX

All Answers

JeremyKraybillJeremyKraybill

Hi Andy,

 

from memory I believe your actionSupport event needs to be onclick, not onchange.

 

HTH

 

Jeremy Kraybill

Austin, TX

This was selected as the best answer
Big EarsBig Ears

Jeremy,

 

You are correct! Thank you.

 

Andy

Message Edited by Big Ears on 02-11-2009 03:27 AM