Creating a spinner for choosing country code

后端 未结 3 1740
生来不讨喜
生来不讨喜 2020-12-30 11:45

I want to create a spinner for selecting a country and getting its country code.

I already found this item list:



        
3条回答
  •  攒了一身酷
    2020-12-30 12:14

    These are ISO 3166-1 alpha-2 codes. You can find a complete list on the ISO's website.

    Running the following code in the JavaScript console (tested using Chrome) gives you a map from codes to countries in JSON format:

    var result = {}
    var rows = document.getElementsByTagName('tr');
    for (var i=1; i

提交回复
热议问题