Generic Country & State Dropdown List – countries.js

Category: Form , Javascript | February 6, 2015
Author:IshanDemon
Views Total:79,779 views
Official Page:Go to website
Last Update:February 6, 2015
License:MIT

Preview:

Generic Country & State Dropdown List – countries.js

Description:

A JavaScript library to create country & state dropdown lists containing all the country names and state names.

How to use it:

Load the countries.js JS library in your project.

<script src="countries.js"></script>

Create select list for country & state selection.

<select id="country" name="country"></select>
<select name="state" id="state"></select>

You Might Be Interested In:


25 thoughts on “Generic Country & State Dropdown List – countries.js

  1. Maher Nabeel

    this is pretty awesome. I think you should include this snippet on How to use section:

    populateCountries(“country”);

    Reply
  2. Chris

    The only naming error i found so far is Romania is incorrectly spelled Romainia

    Reply
  3. Mastermind

    I can seem to get the value of the dropdown on submit. I’m sing php to post the selected country and state to database but value comes empty. Any help please?

    Reply
  4. AndyInLondon77

    You could try http://geodata.solutions – they just give you a bit of code to paste into your site and by the power of ajax it’s all done for you. There’s even lots of configuration options.

    Reply
    1. Azim Khan

      I used it for while integrating was working fine. suddenly stopped not getting any response in api call.
      not good for production.

      Reply
  5. Mohit

    But I need City js file also which will include individual state city ,so could u plz help me?

    Reply
    1. AndyInLondon77

      Oh, I think what you mean is to just have the cities from one state in a dropdown. Is that what you want?

      Reply
  6. Mohit

    This is really awesome ,and it works very well in my website,but i want city js file also .

    Reply
    1. AndyInLondon77

      Are you saying that you’d like a city dropdown for a single country with the cities grouped by state (like you can group countries by continent?). I could look into this for you

      Reply
  7. Prabhu

    This is really awesome.But I want to load a particular country and particular state.So could u please help me.?

    Reply
  8. Nemanja Boskovic

    Yugoslavia fell apart in 2000. please update the countries list…

    Reply
  9. lksjdkf sflkjsdkfj sfkjsldfk

    Country dropdown working, but State and City values not working.

    Reply
  10. sathya

    HI, i have tried to use it, but its not working for me.can you help on this

    Reply
  11. Ameya K

    this code is awesome..!
    Thanks a lot!
    Yet, It would have been much more helpful if could get an additional list of CITIES..

    Thank you !

    Reply
  12. luckw

    There is any way to add by class and same class use multiple counties and state select?

    Reply
  13. dhanesha

    how to use this on update page of php? country and state selected as per user’s country and state which is store on database

    Reply
  14. Amanda Snyder

    Thank you so much for this script, you’ve helped me a lot and I’m grateful to you.

    Reply

Leave a Reply