+ Start a Discussion
Suresh KalluriSuresh Kalluri 

Can we make a field visible on pagelayout based on a picklist value??

There is one picklist and 3 text fields on a page layout.

If the picklist value is 'New'..one more text field should get displayed on the page layout..

For all other values only three text fields should be there..

How can we achieve this??



You can use javascript to do this. You have to simplay make that field inside the div tag and make the display= none and whenever that picklist value become desired value then make the visibility of this field as block.You have to call the javascript method whenever onchanged event is fired from trigger.


Try the below code as reference:

<apex:inputfiled value=”{!PicklistFiled}” onchanged=”show()” id=”id1’ />
<div style=”display:none;" id=”div1”>
<apex:inputtext value=”wind with desired value”/>
Function show()
var state = document.getElementById(id1). value;
if (state == 'Make your own value to whom you want to check') {
document.getElementById(div1).style. display= 'block';
} else {
document.getElementById(div1).style.display= 'none';



For more details go through the link below:


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Suresh KalluriSuresh Kalluri

Cant we do it without using javascript..!!


What you are trying to do is not possible on a native page. You will need to create a VF page with JS as suggested in the earlier post. If you need to retain the native look and feel however, that is possible with a simple attribute on the VF page. Refer the VF workbook for more details.


not sure but try to explore "dependent picklist"

Sam at CMRSam at CMR

If you have Enterprise or Unlimitied you can do this through record types and workflow.


Create a page layout that has the Text Box underneath the PIcklist


Create Record Type and assign the page layout to that Record TYpe (dont assign this record type to any profile so that they are not forced to make a choice when creating a new record)


Create a workflow rule to update the record type when the appropriate value is selected from the picklist

pavan kumar 177pavan kumar 177

I think it's work fine.Please change the code based on our requirement @Suresh Kalluri

<apex:page standardController="Opportunity">
    <apex:form >
    <apex:pageMessages id="theMessage"/>
                 <apex:pageBlock id="thePageBlock">
                          <apex:pageBlockSection columns="2">
                                  <apex:actionRegion >
                                      <apex:inputfield value="{!Opportunity.Type}" id="Type">
                                      <apex:actionSupport event="onchange" rerender="ProdFamilyModel,theMessage"/> 
                                      <apex:inputfield value="{!Opportunity.LeadSource}"/> 
                        <apex:outputPanel id="ProdFamilyModel">
                        <apex:pageBlockSection columns="2" id="ProdFamily"  rendered="{!IF(Opportunity.Type == 'New Customer', true, false)}"> 
                            <apex:inputfield value="{!Opportunity.LeadValue__c}"/>