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
sapthagiri_186sapthagiri_186 

Dependent Picklist to be shown in visualforce page

Hi all,

 

I have a requirement where there are two picklist (Region and City Names) in the same object. Upon selecting Region, its respective Cities must be seen in the City Names picklist and I have made these two as dependent picklist. Here, I am using a VF page and I am not able to achieve dependent picklist. 

 

So, I need a help in here to get my issue solved.

 

Best Regards

@anilbathula@@anilbathula@

HI

 

Try this code:-

 

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >              
                <apex:inputField value="{!Account.Region__c}"/>
                <apex:inputField value="{!Account.Cities__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Ankit AroraAnkit Arora

if you have the picklist dependent on object then you only need to show them up on visualforce page using inputfield, and it will work.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

sapthagiri_186sapthagiri_186

Hi Anil and Ankit,

 

In the object, I have defined these two picklists (Region__c & Cityt__c) as dependent ones. 

I did try this already and here is what I had written:

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Regions" style="position:relative;left:-100px"/>
    <apex:inputField value="{!LeadInfo.Region__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
    <apex:outputLabel value="City" style="position:relative;left:-60px"/>
    <apex:inputField value="{!LeadInfo.City__c}"/>
</apex:pageBlockSectionItem>


/*Class*/

public Lead__c LeadInfo = new Lead__c();
public Lead__c getLeadInfo()
{
return LeadInfo;
}