function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChrisSargentChrisSargent 

Show / Hide Blocks or Elements based on the selection of a Checkbox

Hello,

We have a New Candidate wizard that was built for us in Visual Force / Apex. I would like to slightly modify it so that one section isn't displayed until the user ticks a check box (and should disappear if they unselect it again).

Here is a snippet of the code we currently have
           
            <apex:pageBlockSection columns="1" rendered="{!wizardState == 6 || showAll == true}" title="Opportunity Information:">
               
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Did you speak to this candidate about a live opportunity?</apex:outputLabel>
                    <apex:inputCheckbox value="{!oppAdded}"/>
                </apex:pageBlockSectionItem>
               
                <apex:inputField required="false" value="{!ica.Opportunity__c}" /> 
                <apex:repeat value="{!$ObjectType.IdentifiedCandidateAssociation__c.FieldSets.Candidate_Fields}" var="f"> 
                    <apex:inputfield value="{!ica[f]}"/>
                </apex:repeat>  
                                         
            </apex:pageBlockSection>

I would like it to only display the field from the IdentifiedCandidateAssociation, if the checkbox in the first item is ticked. Is this possible please and can anyone give me some pointers?

I did find this: http://stackoverflow.com/questions/8578748/display-a-text-field-after-a-checkbox-is-checked-in-visualforce but I couldn't use the Disable attribute with an inputField.

Thanks very much!

Chris
Ankit Gupta@ DeveloperAnkit Gupta@ Developer
Hi,

On the checkox click call a class method through acction support and set the flag true or flase on the basis of checkbox value. and rerender the panel which you want to hide/show.