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
uday kumar yuday kumar y 

I have different object like Country,State,District,Village If Click Country Like India it will automaticlly display the States,Districts,Villages

<apex:page controller="Dependentpicklist">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
   <apex:selectList value="{!selectCountry}" size="1">
        Country<apex:selectOptions value="{!Options}"/>
           <apex:actionSupport event="onchange" action="{!FetchState}" reRender="OutState"/>
</apex:selectList>
   <apex:outputPanel id="OutState">
       <apex:selectList value="{!selectState}" size="1">
            State<apex:selectOptions value="{!StateOptions}"/>
               <apex:actionSupport event="onchange" action="{!FetchDistrict}" reRender="OutDist"/>
</apex:selectList>
   <apex:outputPanel id="OutDist">
       <apex:selectList value="{!selectDistrict}" size="1">
           District<apex:selectOptions value="{!DistrictOptions}"/>
               <apex:actionSupport event="onchange" action="{!FetchVillage}" reRender="OutVig"/>
</apex:selectList>
   <apex:outputPanel id="OutVig">
       <apex:selectList value="{!selectVillage}" size="1">
           Village<apex:selectOptions value="{!VillageOptions}"/>
</apex:selectList>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form> 
</apex:page>



public class Dependentpicklist{
   public string selectCountry{set;get;}
   public string selectState{set;get;}
   public string selectDistrict{set;get;}
   public string selectVillage{set;get;}
   public List<Selectoption> Options{set;get;}
   public List<Selectoption> StateOptions{set;get;}
   public List<selectoption> DistrictOptions{set;get;}
   public List<selectoption> VillageOptions{set;get;}
   
   
   public Dependentpicklist(){
       Options = new List<Selectoption>();
           for(Country__c cou:[select Id,Name from Country__c]){
              Options.add(new Selectoption(cou.Id,cou.Name));
           }
   }
   public void FetchState(){
      StateOptions = new List<Selectoption>();
          for(State__c st:[select Id,Name from State__c where Country__c =:selectCountry]){
              StateOptions.add(new Selectoption(st.Id,st.Name));
          } 
   }
   public void FetchDistrict(){
       DistrictOptions = new List<Selectoption>();
           for(District__c dis:[select Id,Name from District__c where State__c =:selectState]){
               DistrictOptions.add(new Selectoption(dis.Id,dis.Name));
           }
   }
   public void FetchVillage(){
       VillageOptions = new List<Selectoption>();
           for(Village__c vlg:[select Id,Name from Village__c where District__c =:selectDistrict]){
               VillageOptions.add(new Selectoption(vlg.Id,vlg.Name));
           }
   }
}

if i select country before will be display NONE value .then if you select any country then automatically displays the states,districts,villages 
Samadhan ForceSamadhan Force
Hi,
try following code, it will help you
 
<apex:page controller="Dependentpicklist">
<apex:form >

<apex:outputPanel style="display:block;text-align:center;margin-top:15px;margin-bottom:15px;">
	<apex:actionstatus id="fetchStaus">
		<apex:facet name="start"> 
		<span style="color:red;font-weight:bold;padding-left:5px;">fetching...</span>
		<img src="/img/loading.gif" alt="" />
		</apex:facet>
	</apex:actionstatus>
</apex:outputPanel>

<apex:pageBlock>
<apex:pageBlockSection >
   <apex:selectList value="{!selectCountry}" size="1">
        Country<apex:selectOptions value="{!Options}"/>
           <apex:actionSupport event="onchange" action="{!FetchState}" reRender="OutState"/>
</apex:selectList>
   <apex:outputPanel id="OutState">
       <apex:selectList value="{!selectState}" size="1">
            State<apex:selectOptions value="{!StateOptions}"/>
               <apex:actionSupport event="onchange" action="{!FetchDistrict}" reRender="OutDist"/>
</apex:selectList>
   <apex:outputPanel id="OutDist">
       <apex:selectList value="{!selectDistrict}" size="1">
           District<apex:selectOptions value="{!DistrictOptions}"/>
               <apex:actionSupport event="onchange" action="{!FetchVillage}" reRender="OutVig"/>
</apex:selectList>
   <apex:outputPanel id="OutVig">
       <apex:selectList value="{!selectVillage}" size="1">
           Village<apex:selectOptions value="{!VillageOptions}"/>
</apex:selectList>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form> 
</apex:page>



public class Dependentpicklist{
   public string selectCountry{set;get;}
   public string selectState{set;get;}
   public string selectDistrict{set;get;}
   public string selectVillage{set;get;}
   public List<Selectoption> Options{set;get;}
   public List<Selectoption> StateOptions{set;get;}
   public List<selectoption> DistrictOptions{set;get;}
   public List<selectoption> VillageOptions{set;get;}
   
   
   public Dependentpicklist(){
       Options = new List<Selectoption>();
							Options.add(new Selectoption('','--None--'));
							
							StateOptions = new List<Selectoption>();
						 StateOptions.add(new Selectoption('','--None--'));       
							
							DistrictOptions = new List<Selectoption>();
							DistrictOptions.add(new Selectoption('','--None--'));   
							
							VillageOptions = new List<Selectoption>();
							VillageOptions.add(new Selectoption('','--None--'));   
							
							for(Country__c cou:[select Id,Name from Country__c]){
										Options.add(new Selectoption(cou.Id,cou.Name));
							}
   }
			
   public void FetchState(){
      StateOptions = new List<Selectoption>();
						StateOptions.add(new Selectoption('','--None--'));       
							for(State__c st:[select Id,Name from State__c where Country__c =:selectCountry]){
              StateOptions.add(new Selectoption(st.Id,st.Name));
          } 
   }
   
			public void FetchDistrict(){
       DistrictOptions = new List<Selectoption>();
							DistrictOptions.add(new Selectoption('','--None--'));   
           for(District__c dis:[select Id,Name from District__c where State__c =:selectState]){
               DistrictOptions.add(new Selectoption(dis.Id,dis.Name));
           }
   }
   
			public void FetchVillage(){
       VillageOptions = new List<Selectoption>();
							VillageOptions.add(new Selectoption('','--None--'));   
           for(Village__c vlg:[select Id,Name from Village__c where District__c =:selectDistrict]){
               VillageOptions.add(new Selectoption(vlg.Id,vlg.Name));
           }
   }
}
--
SamadhanForce