+ Start a Discussion
anil sahooanil sahoo 

show hide section based on a picklist value on an edit page

I have a requirement where a user needs to fill up certain group of fields on a page layout


Im simulating the problem below.


For example, we have a product object and there we have "product name" picklist.


when a user selects "product name" = Car , then the edit page should dynamically render and should show the fields related  ONLY to car.


fields such as : car model, fuel type, color, price etc.


when the user selects product name" = Phone, then the edit page should show fields related to phone only


fields like, phone type, battery capacity, screen size etc.


In this case, the fields related to Car should disappear. And also the information in the car related field if the user had input some information in the car related fields.


then the user should be able to save the record.


* User can only enter information either related to car or related to phone.



My idea is to create 2 sections, one with fields only belong to phone and another section of fields only belong to car. Now the visual force page showed show the correct section based on the picklist value selected.


Please let me know if any one has any working code similar to my requirement.







you want change dynamically fields or fields values 


Please see below examples 


<apex:pageBlock title="some title" rendered="{!if(Opp.Product_Type__c=='Dark',true,false)}">

write some section of fields.



if you want change inside section based section field values


<apex:inputField value="{!Opp.some__c}" rendered="{!Oppsome.End__c=='net'}"/>


Note:I used example field names. 

anil sahooanil sahoo

could you please explain the solution in bit detail? i hardly got the solution.







please see below example 


i have different record types .  i have input field on page layout  for record type selection . when record type changes , the section of fields also change 


        <apex:outputLabel styleClass="label">Item Type: </apex:outputLabel>

        <apex:inputField value="{!OppLineItem.Product_Type__c}" >

            <apex:actionSupport event="onchange" reRender="frm" status="Stat" action="{!SelectProductType}"  />


// record type = data center

<apex:pageBlock title="some title" rendered="{!if(OppLineItem.Product_Type__c=='Data Center',true,false)}">

           <apex:pageBlockSection columns="2" >

                <apex:inputField value="{!OppLineItem.Location__c}"   />

                <apex:inputField value="{!OppLineItem.Rack_Height__c}"  />

                <apex:inputField value="{!OppLineItem.Power_require__c}"  />

                <apex:outputLabel />

                <apex:commandButton value="GetProducts" action="{!getProducts}" />





Dileep A 3Dileep A 3

I am working with the similar requirement, can you please help me with this. I am selecting the picklist values and when i am selecting the particular value it is showing and when i deselect that value it is not getting hide, Is that possible to show and hide based up on the particular value.

As mentioned in the screenshot: when we are selcting Greenback then Greenback Amount and Greenback Format should display and when we deselect that Greenback then dependent fields should hide, Is that possible?User-added image