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
sagarrrrsagarrrr 

Create a Visual Force page. This page should display two picklists, one for Country and another for City. Initially city picklist should not display any value; instead it should be dependent upon Country picklist. So when user selects a pa rtic

Create a list custom setting named “Country”. Create four records of this custom setting:
1. Name = India
2. Name = France
3. Name = Italy
4. Name = USA
Create another list custom setting named “City”. Add a field “Country” of data type text on this
custom setting.
Create following records of this custom setting:
1. Name = New Delhi, Country = India
2. Name = Mumbai, Country = India
3. Name = Pu ne, Country = India
4. Name = Kolkata, Country = India
5. Name = Ney York, Country = USA
6. Name = Miami, Country = USA
7. Name = Washington DC, Country = USA
8. Name = Paris, Country = France
9. Name = Lyon, Country = France
10. Name = Milan, Country = Italy
11. Name = Rome, Country = Italy

Create a Visual Force page. This page should display two picklists, one for Country and another for City. Initially city picklist should not display any value; instead, it should be dependent upon Country picklist. So when the user selects a particular country then City picklist should load all the cities corresponding to the selected country.

plz help in this question i have created 2 custom setting name as city and country but i am stuck in vf page plz any one help me 
thank you 
Bhaskar K 50Bhaskar K 50

you can use dependent pick list

for more info https://success.salesforce.com/answers?id=90630000000hXlTAAU

Dushyant srivastava 8Dushyant srivastava 8
Hi Sagar,

If you have these picklist on an Object then you can go for Dependent Picklist else You have to controll the same on Visualforce Page and its contoller.

Simplest way to do so, create a Map of map<String , List<String>>. Like:
 
Map<String, List<String>> mapCon = new Map<String, List<String>>{'India' => new List<String>{'New Delhi', 'Mumbai', 'Pune', 'kolkata'} , 'USA' => new List<String>{''New York','Miami'}};
Show the 1st picklist as Key of map and the 2nd picklist will pay along with values of the Key.

You can also try custom setting to be more dynamic, store all the values in custom setting and add those in the map and show it in Visualforce Page.

 
sagarrrrsagarrrr
Hi  Bhaskar,
i want to complete this question with help of custom setting.
thank you
sagarrrrsagarrrr
Hi Dushyant,
I want to complete this question with the help of a custom setting. And i have created the vf Page for this but I am stuck in Apex Class.
So Can you help me apex class.

 VF CODE-

<apex:page controller="c10">
   <apex:form >
      <apex:actionFunction name="rerenderCity" rerender="statesSelectList" >
          <apex:param name="firstParam" assignTo="{!country}" value="" />
      </apex:actionFunction>

   <table><tbody>
      <tr>
        <th>Country</th>
          <td>
             <apex:selectList id="country" styleclass="std" size="1" 
                value="{!country}" onChange="rerenderCity(this.value)">
                    <apex:selectOptions value="{!countriesSelectList}"/>
             </apex:selectList>
          </td>
      </tr>
       
      <tr id="city_input">
        <th>City</th>
          <td>
            <apex:selectList id="citySelectList" styleclass="std" size="1" 
                 value="{!city}">
                   <apex:selectOptions value="{!citySelectList}"/>
            </apex:selectList>
          </td>
      </tr>
   </tbody></table>
   </apex:form>
</apex:page>
sagarrrrsagarrrr
User-added imageUser-added image
I have already created two custom settings with the name Country and City.
Dushyant srivastava 8Dushyant srivastava 8
Sagar,

This can be done by single custom setting Name the records of custom setting as Country name and its field as City's.

In the class you have to create the map like:
 
public class c10
{
    public static Map<String, List<String>> mapCon {get ; set;}
    
    public void c10()
    {
        mapCon = new Map<String, List<String>>{'India' => new List<String>{'New Delhi', 'Mumbai', 'Pune', 'kolkata'} , 'USA' => new List<String>{'New York','Miami'}};
    }
}

Once its done the same map can be used in the Visualforce page.

Let me know if it helps!!!!
sagarrrrsagarrrr
Hi Dushyant,

But the requirement is different. So can you help me !!

Thank you