Country list and code

1

I have researched in several places and did not find it. If someone has or knows where I can find a javascript that brings COUNTRY + COUNTRY CODE, could you give a help? I need to pro-social project, as follows validation table of it.

    
asked by anonymous 23.01.2018 / 11:56

2 answers

2

In the Github repository below you have json files and other formats following the ISO 3166-1 , which specifies the representation of countries in 2 letter, 3 letter and 3 digit code format

link

GitHub repository, with JSON file according to Annex I Table 06 - eSocial version 2.4.01 readings;

link

You can grab this file and load it into memory as a Object Array , or use frameworks such as: NodeJS or Angular. To read this file on your local host.

An example if you load into memory:

var paises = [{
    "codigo": 13,
    "pais": "Afeganistao",
    "criacao": "-",
    "extincao": ""
  },
  {
    "codigo": 17,
    "pais": "Albania, Republica Da",
    "criacao": "-",
    "extincao": ""
  }
];

function popular() {

  var table = document.getElementsByTagName("table")[0];
  var tbody = table.getElementsByTagName("tbody")[0];
  
  for (var i = 0; i < paises.length; i++) {
  
  tbody.innerHTML +=
  "<tr><td>" + paises[i].codigo + "</td><td>" 
             + paises[i].pais + "</td><td>" 
             + paises[i].criacao + "</td><td>" 
             + paises[i].extincao + "</td></tr>";
  }
}
<html>

<body onload="popular()">
  <div class="tabela">
    <table>
      <thead>
        <tr>
          <td>Codigo</td>
          <td>Paises</td>
          <td>Criação</td>
          <td>Extinção</td>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
  </div>
</body>

</html>

Note: Always provide a minimal example in code.

    
23.01.2018 / 12:17
0

I do not know any APIs that can get such data.

I think it's easier to create a table for query.

Use the SmallPDF to convert the PDF and import the data into your table.

    
23.01.2018 / 12:13