Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Country state/city dropdown in html and javascript

Is there any readily available snippet that has all the countries, states and cities for showing in a drop down in html for selection?

What is standard for this? Does everyone roll their own?

The snippet can be in html, javascript, jquery plugin.

NOTE: I know how to make chained dropdown. I'm more concerned with the data rather than technique.

like image 991
Muhammad Hasan Khan Avatar asked Jul 12 '11 05:07

Muhammad Hasan Khan


1 Answers

Any code containing all that data would be a lot more than a snippet. I don't think you'll find a standard component for this, and I wouldn't trust any I found that claim to. There's too much subjectivity along with making your own judgements about how comprehensive you want to be.

  • This sort of data changes constantly and in many cases isn't universally agreed upon. I see you're from Pakistan; under which country should Kashmir be listed? See also: Burma (or do I mean Myanmar?)
  • Not everything fits neatly into city/state/country classes. Should Puerto Rico be listed as a country or a US state? Then you've got Crown Dependencies, Outlying Territories, Protectorates, Self-governing Colonies, etc.
  • Compiling a complete list of states (more generally Subnational entities, to include territories, districts, provinces, prefectures and lots more) and especially cities (do you really want to include Lost Springs, Wyoming, population :1?) would be quite an accomplishment. I'm not sure even the CIA World Factbook is that comprehensive.

Some other good sources when rolling your own are

  • ISO Country Codes
  • ISO state codes
like image 102
Brad Mace Avatar answered Oct 26 '22 13:10

Brad Mace