+ 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??

Navatar_DbSupNavatar_DbSup

Hi,


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”/>
</div>
<script>
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';
}
}
</script>

 

 

For more details go through the link below:
http://www.webmasterworld.com/forum91/441.htm

 

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..!!

msingh.ax1244msingh.ax1244

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.

Teach_me_howTeach_me_how

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>
                                  </apex:actionRegion>
                                      <apex:inputfield value="{!Opportunity.LeadSource}"/> 
                          </apex:pageBlockSection>
                        <apex:outputPanel id="ProdFamilyModel">
                        <apex:pageBlockSection columns="2" id="ProdFamily"  rendered="{!IF(Opportunity.Type == 'New Customer', true, false)}"> 
                            <apex:inputfield value="{!Opportunity.LeadValue__c}"/>
                 </apex:pageBlockSection> 
    </apex:outputPanel> 
    </apex:pageBlock>
    </apex:form> 
</apex:page>