Atthapon Junpun-eak
Atthapon Junpun-eak

Reputation: 540

How to make the cities/countries dropdown like facebook does?

See the screenshot here:
http://media-cdn.pinterest.com/upload/185773553348981093_6T1oUT9E.jpg

I'd like the user to just type a city or country name and the autocompleter will show suggested items.

How should I start for creating it? Are there any API(s) or web services for me to call? Where can I find the database of all cities/countries in the world?

Upvotes: 4

Views: 6781

Answers (3)

evotopid
evotopid

Reputation: 5429

You first need a autocomplete plugin.
I recommend to use the jQuery-Ui Auto Complete Plugin.

The database could as example be this, but eventually try to search a bit for yourself.
There was already a question on stackoverflow about a database for cities of the world.
A simple text file with all cities may also be this.
There are very much of those libraries, but you have to chose the right one for you.

Upvotes: 2

Sven
Sven

Reputation: 13296

My solution may not be the best, but it's a starting point: Google a list with all countries (ISO-Standard), paste it into a txt-file. Then you can simply read that file with PHP an create a select menu with the contents of the file. It does not incorporate the cities, but maybe it helps you in some way.

Upvotes: 0

Alex
Alex

Reputation: 6159

I think this would be the best database for your situation, check it out:

http://www.geodatasource.com/cities-free.html

Upvotes: 4

Related Questions