How easy (or difficult) is it to have a Continent/Country/City drop down menu?

Where one select from Drop Down Menus (for example):

1 - Europe

2 - UK

3 - London

and then writes the Province/Area (for example: Essex).

Realistically, how long should it take an experienced web developer to write the code of the above, as well as to link this selection to a Browse function and database storing?

I do not have a geographical database yet and I am wondering what the fastest and cheapest way to add it to the drop down menu is. Is there any way to get that geographical database for free?

I can see this type of geographical drop down menu in thousands of websites, but I am struggling as to how to implement it ASAP.

Follow Up: Tks All x your answers and comments so far. I hear what you are saying. I understand that there are rare occasions of Countries with multiple (same) name Cities and that it might be disputable whether a Country belongs to a certain Continent/Region or not (see Russia x example, Europe or Asia?). Anyway, please take a look, for instance, at this website Sign UP screen http://www.couchsurfing.org/register.html My question then is: Where do I get that list (Country/Cities) and how do I create that _array? Manually copying it somewhere else (which would take me ages) or are there ready made lists that can be downloaded from somewhere for free?

Follow Up n2: No way I plan to re-write the whole planisphere! I do agree, to a certain extent, that the number of Countries on this Planet is not fixed and this very issue is arguable (I've Googled: "How many Countries are there in the world?" and realized that there are different answers, however, I haven't got time to keep up to date with the ever shifting political landscape and engage into such debate). Irrespective of the argument between the Commentators below, all I just need is a straight and practical solution: a ready made list (database) of Countries/Cities (to use as _Array) in my DropDownMenus, exactly like the one on http://www.couchsurfing.org/register.html Has anyone got a clue where to get that list please?

  • So you want Continent/Country/City as dropdowns, but you want Province/Area as a text field? The first thing that jumps out at me is that countries frequently have multiple cities with the same name. See: Springfield
    – Jay
    Mar 10 '11 at 16:47
  • 1
    Since no one agrees on what a "country" is, and there's no authoritative list of countries, you have a bit of problem. Perhaps you should update your question to be more specific on where you're getting this list of "countries" and "continents" from.
    – S.Lott
    Mar 10 '11 at 18:43
  • 3
    What happens to Turkey and Russia? I don't see the need for a continent drop down. It complicates a lots the issue and adds no value.
    – Vitor Py
    Mar 10 '11 at 19:15
  • @S.Lott - The list of countries recognized by the UN (or it's expanded edition, google: "list of sovereign states") is enough for most practical purposes. It's not like it's changed on a daily basis.
    – Rook
    Mar 11 '11 at 5:46
  • @Rook: "enough for most practical purposes". Until you piss off your users by failing to list their country or listing a country which they actively dispute the existence of. Then the "practical" devolves into help-desk flamewars and government firewalling.
    – S.Lott
    Mar 11 '11 at 11:00

This is such a common scenario when developing a public web application nowadays.

To answer your question, directly, it shouldn't take an experienced developer more than a few hours to implement a typical address form.

That said, the typical address form has dropdowns for Country and State/Province, but not City or Continent. City is always text entry, and Continent is normally not represented. This is true even of your couchsurfing.org example.

As for the data, I use Country and State/Province lists derived from ISO 3166-1/2


Assuming you have the data already to hand and stored in a sensible manner this should be a half hour job. The problem is getting the data right, a hierarchy of three lists should be simple. Is this really what you want though? Are you limitting what can be input to the accuracy of the data that you have. Chances are for input from a large geographical spread you are going to get areas and terminology wrong and people can get very fussy about having their geographical information misrepresented, such are being told you live in Edinburgh, Scotland, England.

  • Having Drop Down Menus would limit the likelyhood of mispelling (i.e. New Yorl instead of New York) hence a missed mistatch with the Browse function and proper database/stats accruals.
    – Dave
    Mar 10 '11 at 18:51

Could be anywhere from a week to a few hours, IMO. The week is the case where you have translations, content management systems and other components to consider in your solution and even if you do know these well the testing for it may take some time to verify in all browsers and languages. The other extreme is the case where a site already has this code and someone is merely plugging into that code by updating some configuration stuff and testing that which is where most of the time could be spent again.

Sometimes there will already be lists of countries and provinces/states that can be leveraged within an existing infrastructure though if you had to build it from scratch it could depend on the system you are using as a manually managed list wouldn't take more than a few hours. I could also picture in some content management systems wanting to have an automated script to handle generating the content items but that would likely only take about a day at the most unless the system is rather slow and fragile as an automated script could run overnight to generate the items once the basics of a script to generate all the inside content can be done. Course defining how big an area has to be to be a city is another issue but that's another debate to be had, IMO.

  • Tks vm
    – Dave
    Mar 10 '11 at 18:47

So you plan to create a list of cities for each country on earth? Do you know how many cities there are in just the United States? There are about 300 in the list of those over 100K people. If that ratio (about 1 100K city/million citizens) works for the entire planet, there are about 7000 cities on this lonely orb. Have fun typing.


Why not just do a View Source on that web site you keep listing and pull the list from there if that is exactly what you want?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.