How to select city in a picklist by selecting a state in another picklist?
How to select city in a picklist by selecting a state in another picklist?
I have made an object called "State". There are three custom fields :
1. State
2. City
3. Village
in this object.
I have made picklists for state, city and village . I want that whenever i select a state, city associated with this state got select. And also when i want that whenever i select a city, Village associated with this city got select.If you have any solution please tell me.Thanks .
</apex:form> <script> function searchCity(){ // alert('hiiiiiiiiiii'); getCities(); } function searchVillage() { // alert('hello'); getVillages(); } </script> </apex:page> For controller public class sampleCon { String id; public StateCity__c State{get;set;} public StateCity__c City{get;set;} public StateCity__c Village{get;set;}
public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('id','Rajasthan')); options.add(new SelectOption('id','MP')); return options; }
public List<SelectOption> getCities() { id = ApexPages.currentPage().getParameters().get('id'); List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('id','Ajmer')); options.add(new SelectOption('id','Bhopal')); return options; }
public List<SelectOption> getVillages() { id = ApexPages.currentPage().getParameters().get('id'); List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('id','Kishangarh')); options.add(new SelectOption('id','Nimach')); return options; } }
Have you tried to achieve this via Dependent Picklists?
No i did not try this wia dependent picklist.
Sorry sir i am unable to get my answer through your blog.Please sir can you tell me the right solution from code i have written?