0

I have a visualforce form- included in this form are three checkboxes. Two of the checkboxes are additional questions following on from the first, so I only want them to show on the page when the first checkbox is clicked to true.

I have tried to do this using actionSupport, but it seems to have broken my checkbox (label not showing) and the actionSupport doesn't seem to cause the additional checkboxes to rerender. Where am I going wrong?

Code:

<apex:actionRegion>
                <apex:inputField value="{! custom.cloneProductsBool__c }" label="Clone Products" required="true">
                    <apex:actionSupport event="onchange" reRender="checkboxes"/>
                </apex:inputField>
                <apex:outputPanel id="checkboxes" rendered="{! custom.cloneProductsBool__c}">
                    <apex:inputField value="{! custom.removeDiscountsBool__c }" label="Remove discounts"/>
                    <apex:inputField value="{! custom.removeNumbersBool__c }" label="Remove Numbers" />
                </apex:outputPanel>               
</apex:actionRegion>
1
2

There is an issue when you try to reRender a conditionally rendered outputPanel (because it was never in the DOM to begin with). Add the conditional rendering on the individual fields or a sub tag from the outputPanel as follows (I tested and works just fine)

<apex:form>
    <apex:inputField value="{! Account.Checkbox1__c }">
        <apex:actionSupport event="onchange" rerender="checkboxes" />
    </apex:inputField>
    <apex:outputPanel id="checkboxes">
        <apex:inputField value="{! Account.Checkbox2__c }" label="Remove discounts" rendered="{!Account.Checkbox1__c}" />
        <apex:inputField value="{! Account.Checkbox3__c }" label="Remove Numbers" rendered="{!Account.Checkbox1__c}" />
    </apex:outputPanel>
</apex:form>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.