I have a dropdown firm filed with countries like "Belgium", "Barbados" etc with id = "country" and another text input with phone number to be filled with id = "tele". I need the country calling code to be updated in the tele id input filed based on country dropdown. I have a json file of country calling code mapped to country names in format (countrycode.json):
{
  "countries": [
    {
      "code": "+7 840",
      "name": "Abkhazia"
    },
    {
      "code": "+93",
      "name": "Afghanistan"
    },
etc....
My current jQuery code is as follows:
<script>
$('#country').change(function() {
    var countrycode = $(this).val();
    $('#tele').val(countrycode);
});
</script>
which will update the tele id with value from country id.
I need the country calling code to be selected from the json file based on the country chosen. How is it possible?
Thanks in advance.
 
     
    