0

I have two objects has look up realtion to each other. I have created both has picklist on VF page now I want to load one picklist values on the selection of another picklist values. Like All Sate should come on the basis of country like that. Please help, thanks in advance.

Regards Raman

This is my Code:

Congratulations

This is your Accession Page !!

           <apex:pageBlockSection id="detailsFacility">
                 <apex:selectList required="true" multiselect="false" size="1" label="Facility"   style="align:left">
                    <apex:selectOptions value="{!FacilityOption}" />
                </apex:selectList>
           </apex:pageBlockSection> 

public class ExtentionController
{
public string ClientSelectedValue {get;set;}
public Client__c ClientFacilityList{get;set;}

public ExtentionController()
    {

}
public List<selectOption> Clientoption
    {
     get
     {
         List<selectOption> ClientName= new List<selectOption>();
         ClientName.add(new selectOption('None','None'));
         for(Client__c cn : [select ID, Name,ClientName__c from Client__c] )
         ClientName.add(new selectOption(cn.Name,cn.ClientName__c));
         return ClientName; 
     }

         private set;
   }


public List<selectOption> FacilityOption
    {

     get
     {
         string clientId = ClientselectedValue;
         List<selectOption> FacilityName= new List<selectOption>();
         if(clientId == '' || clientId == null) 
         {
         FacilityName.add(new selectOption('None','None'));
         }
         else
         {
         ClientFacilityList = [select  id, ClientName__c from Client__c where   name =:clientId  ];
         for(Facilty__c fn: [select ID, Name,FacilityName__c from Facilty__c where Client__c=:ClientFacilityList.id] )
         FacilityName.add(new selectOption(fn.Name,fn.FacilityName__c));
         }
         return FacilityName; 
     }

     private set;
   }
}

1 Answer 1

1

Create a dependent pick-list for the object you are referencing on visualforce page

http://na9.salesforce.com/help/doc/en/fields_defining_field_dependencies.htm

You can reference this on visualforce as well.

An example is shown in the blog below that you can reference

http://www.sundoginteractive.com/sunblog/posts/displaying-dependent-picklist-fields-on-a-visualforce-page

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .