+ Start a Discussion
Narayan HNarayan H 

How can I hide fields conditionally - based on a picklist value

I would like to conditionally hide few fields based on the value of a picklist. What I have is a picklist that shows the specific Account type. Based on that selection I would like to hide some fields so that I can enforce some level of process control.

I really appreciate your help in this regard.
Best Answer chosen by Narayan H
Mohit Bansal6Mohit Bansal6
See below example, i hope it can help you in designing your code. In this code, depending upon Account Type field, the below fields are hidden or displayed.
 
<apex:outputPanel id="t1">
            <apex:pageBlock>
                  <apex:pageBlockSection>
                         <apex:inputField value="{!Account.type}"/> 
                                     <apex:actionSupport event="onchange" rerender="t1" />
                        <apex:inputField id="FieldName" value="{!Account.name}"   rendered="{!Account.Type == 'Partner'}"/>
                        <apex:inputField id="FieldName" value="{!Account.name}"   rendered="{!Account.Type == 'Public'}"/>
                  </apex:pageBlockSection>
              </apex:pageBlock> 
</apex:outputPanel>


Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help

All Answers

Mohit Bansal6Mohit Bansal6
See below example, i hope it can help you in designing your code. In this code, depending upon Account Type field, the below fields are hidden or displayed.
 
<apex:outputPanel id="t1">
            <apex:pageBlock>
                  <apex:pageBlockSection>
                         <apex:inputField value="{!Account.type}"/> 
                                     <apex:actionSupport event="onchange" rerender="t1" />
                        <apex:inputField id="FieldName" value="{!Account.name}"   rendered="{!Account.Type == 'Partner'}"/>
                        <apex:inputField id="FieldName" value="{!Account.name}"   rendered="{!Account.Type == 'Public'}"/>
                  </apex:pageBlockSection>
              </apex:pageBlock> 
</apex:outputPanel>


Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
This was selected as the best answer
Narayan HNarayan H
Thanks Mohit. This was helpful.