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
Sandra OrtizSandra Ortiz 

Display blocksection with input fields based on another field value

I need help displaying the items found within the outputPanel only when my Hours_Type__c field = "Billable"

Any help would be appreciated. I
 
​<apex:page standardController="Work_Order__c">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script>
        window.onload = function(){
        $('input[id$="ReopenTrue"]').prop('checked',true);
    };
    </script>
    
  
    
    <apex:form >
        <apex:pageBlock title="Reopen Work Order: {!Work_Order__c.Name}">
            <apex:pageBlockSection title="Reopen Information" columns="2">
                <apex:inputField value="{!Work_Order__c.Reopen_Reason__c}" required="true"/> 
                <apex:pageBlockSectionItem dataStyle="display:none;" >
                    <apex:inputField value="{!Work_Order__c.Trigger_Reopening__c}" id="ReopenTrue"/> 
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>   
   
   <apex:outputPanel id="Outputs">       
     
        <apex:pageBlockSection title="Billing Information" columns="1"> 
        <apex:pageblocksection ><b>Current Work Order is set to "{!Work_Order__c.Hours_Type__c}" with Non-Billable Reason of "{!Work_Order__c.Non_Billable_Reason__c}"</b>
                </apex:pageBlockSection>
          <apex:inputField value="{!Work_Order__c.What_is_Hours_Type_on_the_Reopened_WO__c}" required="false"/>
          <apex:inputField value="{!Work_Order__c.What_is_the_Non_Billable_Reason__c}" required="true"/>
        </apex:pageBlockSection>   
     </apex:outputPanel>      
      
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Reopen Work Order"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


 
Teddy MwangiTeddy Mwangi
Apply the 'rendered' property on the apex:outputPanel with a boolean expression checking for the Hours_Type__c as having the 'Billable' value. See below!

​<apex:page standardController="Work_Order__c">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script>
        window.onload = function(){
        $('input[id$="ReopenTrue"]').prop('checked',true);
    };
    </script>
    
  
    
    <apex:form >
        <apex:pageBlock title="Reopen Work Order: {!Work_Order__c.Name}">
            <apex:pageBlockSection title="Reopen Information" columns="2">
                <apex:inputField value="{!Work_Order__c.Reopen_Reason__c}" required="true"/> 
                <apex:pageBlockSectionItem dataStyle="display:none;" >
                    <apex:inputField value="{!Work_Order__c.Trigger_Reopening__c}" id="ReopenTrue"/> 
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>   
   
   <apex:outputPanel id="Outputs">       
     
        <apex:pageBlockSection title="Billing Information" columns="1"> 
        <apex:pageblocksection ><b>Current Work Order is set to "{!Work_Order__c.Hours_Type__c}" with Non-Billable Reason of "{!Work_Order__c.Non_Billable_Reason__c}"</b>
                </apex:pageBlockSection>
          <apex:inputField value="{!Work_Order__c.What_is_Hours_Type_on_the_Reopened_WO__c}" required="false"/>
          <apex:inputField value="{!Work_Order__c.What_is_the_Non_Billable_Reason__c}" required="true"/>
        </apex:pageBlockSection>   
     </apex:outputPanel rendered="{!Work_Order__c.Hours_Type__c = 'Billable'}">      
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Reopen Work Order"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>