Skip to content

Instantly share code, notes, and snippets.

@ximik777
Created May 14, 2017 19:34
Show Gist options
  • Save ximik777/30e7eefa9e840c126c176c40e399f24a to your computer and use it in GitHub Desktop.
Save ximik777/30e7eefa9e840c126c176c40e399f24a to your computer and use it in GitHub Desktop.
Country dialing code select drop menu
<?php
// Country code
$countries = array();
$countries[1] = 'Canada (+1)'; // 1 so array doesn't start at 0 and show empty
$countries[] = 'China (+86)';
$countries[] = 'France (+33)';
$countries[] = 'Germany (+49)';
$countries[] = 'India (+91)';
$countries[] = 'Japan (+81)';
$countries[] = 'Pakistan (+92)';
$countries[] = 'United Kingdom (+44)';
$countries[] = 'United States (+1)';
$countries[] = '--';
$countries[] = 'Abkhazia (+7 840)';
$countries[] = 'Abkhazia (+7 940)';
$countries[] = 'Afghanistan (+93)';
$countries[] = 'Albania (+355)';
$countries[] = 'Algeria (+213)';
$countries[] = 'American Samoa (+1 684)';
$countries[] = 'Andorra (+376)';
$countries[] = 'Angola (+244)';
$countries[] = 'Anguilla (+1 264)';
$countries[] = 'Antigua and Barbuda (+1 268)';
$countries[] = 'Argentina (+54)';
$countries[] = 'Armenia (+374)';
$countries[] = 'Aruba (+297)';
$countries[] = 'Ascension (+247)';
$countries[] = 'Australia (+61)';
$countries[] = 'Australian External Territories (+672)';
$countries[] = 'Austria (+43)';
$countries[] = 'Azerbaijan (+994)';
$countries[] = 'Bahamas (+1 242)';
$countries[] = 'Bahrain (+973)';
$countries[] = 'Bangladesh (+880)';
$countries[] = 'Barbados (+1 246)';
$countries[] = 'Barbuda (+1 268)';
$countries[] = 'Belarus (+375)';
$countries[] = 'Belgium (+32)';
$countries[] = 'Belize (+501)';
$countries[] = 'Benin (+229)';
$countries[] = 'Bermuda (+1 441)';
$countries[] = 'Bhutan (+975)';
$countries[] = 'Bolivia (+591)';
$countries[] = 'Bosnia and Herzegovina (+387)';
$countries[] = 'Botswana (+267)';
$countries[] = 'Brazil (+55)';
$countries[] ='British Indian Ocean Territory (+246)';
$countries[] = 'British Virgin Islands (+1 284)';
$countries[] = 'Brunei (+673)';
$countries[] = 'Bulgaria (+359)';
$countries[] = 'Burkina Faso (+226)';
$countries[] = 'Burundi (+257)';
$countries[] = 'Cambodia (+855)';
$countries[] = 'Cameroon (+237)';
$countries[] = 'Canada (+1)';
$countries[] = 'Cape Verde (+238)';
$countries[] = 'Cayman Islands (+ 345)';
$countries[] = 'Central African Republic (+236)';
$countries[] = 'Chad (+235)';
$countries[] = 'Chile (+56)';
$countries[] = 'China (+86)';
$countries[] = 'Christmas Island (+61)';
$countries[] = 'Cocos-Keeling Islands (+61)';
$countries[] = 'Colombia (+57)';
$countries[] = 'Comoros (+269)';
$countries[] = 'Congo (+242)';
$countries[] = 'Congo, Dem. Rep. of (Zaire) (+243)';
$countries[] = 'Cook Islands (+682)';
$countries[] = 'Costa Rica (+506)';
$countries[] = 'Ivory Coast (+225)';
$countries[] = 'Croatia (+385)';
$countries[] = 'Cuba (+53)';
$countries[] = 'Curacao (+599)';
$countries[] = 'Cyprus (+537)';
$countries[] = 'Czech Republic (+420)';
$countries[] = 'Denmark (+45)';
$countries[] = 'Diego Garcia (+246)';
$countries[] = 'Djibouti (+253)';
$countries[] = 'Dominica (+1 767)';
$countries[] = 'Dominican Republic (+1 809)';
$countries[] = 'Dominican Republic (+1 829)';
$countries[] = 'Dominican Republic (+1 849)';
$countries[] = 'East Timor (+670)';
$countries[] = 'Easter Island (+56)';
$countries[] = 'Ecuador (+593)';
$countries[] = 'Egypt (+20)';
$countries[] = 'El Salvador (+503)';
$countries[] = 'Equatorial Guinea (+240)';
$countries[] = 'Eritrea (+291)';
$countries[] = 'Estonia (+372)';
$countries[] = 'Ethiopia (+251)';
$countries[] = 'Falkland Islands (+500)';
$countries[] = 'Faroe Islands (+298)';
$countries[] = 'Fiji (+679)';
$countries[] = 'Finland (+358)';
$countries[] = 'France (+33)';
$countries[] = 'French Antilles (+596)';
$countries[] = 'French Guiana (+594)';
$countries[] = 'French Polynesia (+689)';
$countries[] = 'Gabon (+241)';
$countries[] = 'Gambia (+220)';
$countries[] = 'Georgia (+995)';
$countries[] = 'Germany (+49)';
$countries[] = 'Ghana (+233)';
$countries[] = 'Gibraltar (+350)';
$countries[] = 'Greece (+30)';
$countries[] = 'Greenland (+299)';
$countries[] = 'Grenada (+1 473)';
$countries[] = 'Guadeloupe (+590)';
$countries[] = 'Guam (+1 671)';
$countries[] = 'Guatemala (+502)';
$countries[] = 'Guinea (+224)';
$countries[] = 'Guinea-Bissau (+245)';
$countries[] = 'Guyana (+595)';
$countries[] = 'Haiti (+509)';
$countries[] = 'Honduras (+504)';
$countries[] = 'Hong Kong SAR China (+852)';
$countries[] = 'Hungary (+36)';
$countries[] = 'Iceland (+354)';
$countries[] = 'India (+91)';
$countries[] = 'Indonesia (+62)';
$countries[] = 'Iran (+98)';
$countries[] = 'Iraq (+964)';
$countries[] = 'Ireland (+353)';
$countries[] = 'Israel (+972)';
$countries[] = 'Italy (+39)';
$countries[] = 'Jamaica (+1 876)';
$countries[] = 'Japan (+81)';
$countries[] = 'Jordan (+962)';
$countries[] = 'Kazakhstan (+7 7)';
$countries[] = 'Kenya (+254)';
$countries[] = 'Kiribati (+686)';
$countries[] = 'North Korea (+850)';
$countries[] = 'South Korea (+82)';
$countries[] = 'Kuwait (+965)';
$countries[] = 'Kyrgyzstan (+996)';
$countries[] = 'Laos (+856)';
$countries[] = 'Latvia (+371)';
$countries[] = 'Lebanon (+961)';
$countries[] = 'Lesotho (+266)';
$countries[] = 'Liberia (+231)';
$countries[] = 'Libya (+218)';
$countries[] = 'Liechtenstein (+423)';
$countries[] = 'Lithuania (+370)';
$countries[] = 'Luxembourg (+352)';
$countries[] = 'Macau SAR China (+853)';
$countries[] = 'Macedonia (+389)';
$countries[] = 'Madagascar (+261)';
$countries[] = 'Malawi (+265)';
$countries[] = 'Malaysia (+60)';
$countries[] = 'Maldives (+960)';
$countries[] = 'Mali (+223)';
$countries[] = 'Malta (+356)';
$countries[] = 'Marshall Islands (+692)';
$countries[] = 'Martinique (+596)';
$countries[] = 'Mauritania (+222)';
$countries[] = 'Mauritius (+230)';
$countries[] = 'Mayotte (+262)';
$countries[] = 'Mexico (+52)';
$countries[] = 'Micronesia (+691)';
$countries[] = 'Midway Island (+1 808)';
$countries[] = 'Micronesia (+691)';
$countries[] = 'Moldova (+373)';
$countries[] = 'Monaco (+377)';
$countries[] = 'Mongolia (+976)';
$countries[] = 'Montenegro (+382)';
$countries[] = 'Montserrat (+1664)';
$countries[] = 'Morocco (+212)';
$countries[] = 'Myanmar (+95)';
$countries[] = 'Namibia (+264)';
$countries[] = 'Nauru (+674)';
$countries[] = 'Nepal (+977)';
$countries[] = 'Netherlands (+31)';
$countries[] = 'Netherlands Antilles (+599)';
$countries[] = 'Nevis (+1 869)';
$countries[] = 'New Caledonia (+687)';
$countries[] = 'New Zealand (64)';
$countries[] = 'Nicaragua (+505)';
$countries[] = 'Niger (+227)';
$countries[] = 'Nigeria (+234)';
$countries[] = 'Niue (+683)';
$countries[] = 'Norfolk Island (+672)';
$countries[] = 'Northern Mariana Islands (+1 670)';
$countries[] = 'Norway (+47)';
$countries[] = 'Oman (+968)';
$countries[] = 'Pakistan (+92)';
$countries[] = 'Palau (+680)';
$countries[] = 'Palestinian Territory (+970)';
$countries[] = 'Panama (+507)';
$countries[] = 'Papua New Guinea (+675)';
$countries[] = 'Paraguay (+595)';
$countries[] = 'Peru (+51)';
$countries[] = 'Philippines (+63)';
$countries[] = 'Poland (+48)';
$countries[] = 'Portugal (+351)';
$countries[] = 'Puerto Rico (+1 787)';
$countries[] = 'Puerto Rico (+1 939)';
$countries[] = 'Qatar (+974)';
$countries[] = 'Reunion (+262)';
$countries[] = 'Romania (+40)';
$countries[] = 'Russia (+7)';
$countries[] = 'Rwanda (+250)';
$countries[] = 'Samoa (+685)';
$countries[] = 'San Marino (+378)';
$countries[] = 'Saudi Arabia (+966)';
$countries[] = 'Senegal (+221)';
$countries[] = 'Serbia (+381)';
$countries[] = 'Seychelles (+248)';
$countries[] = 'Sierra Leone (+232)';
$countries[] = 'Singapore (+65)';
$countries[] = 'Slovakia (+421)';
$countries[] = 'Slovenia (+386)';
$countries[] = 'Solomon Islands (+677)';
$countries[] = 'South Africa (+27)';
$countries[] = 'South Georgia and the South Sandwich Islands (+500)';
$countries[] = 'Spain (+34)';
$countries[] = 'Sri Lanka (+94)';
$countries[] = 'Sudan (+249)';
$countries[] = 'Suriname (+597)';
$countries[] = 'Swaziland (+268)';
$countries[] = 'Sweden (+46)';
$countries[] = 'Switzerland (+41)';
$countries[] = 'Syria (+963)';
$countries[] = 'Taiwan (+886)';
$countries[] = 'Tajikistan (+992)';
$countries[] = 'Tanzania (+255)';
$countries[] = 'Thailand (+66)';
$countries[] = 'Timor Leste (+670)';
$countries[] = 'Togo (+228)';
$countries[] = 'Tokelau (+690)';
$countries[] = 'Tonga (+676)';
$countries[] = 'Trinidad and Tobago (+1 868)';
$countries[] = 'Tunisia (+216)';
$countries[] = 'Turkey (+90)';
$countries[] = 'Turkmenistan (+993)';
$countries[] = 'Turks and Caicos Islands (+1 649)';
$countries[] = 'Tuvalu (+688)';
$countries[] = 'Uganda (+256)';
$countries[] = 'Ukraine (+380)';
$countries[] = 'United Arab Emirates (+971)';
$countries[] = 'United Kingdom (+44)';
$countries[] = 'United States (+1)';
$countries[] = 'Uruguay (+598)';
$countries[] = 'U.S. Virgin Islands (+1 340)';
$countries[] = 'Uzbekistan (+998)';
$countries[] = 'Vanuatu (+678)';
$countries[] = 'Venezuela (+58)';
$countries[] = 'Vietnam (+84)';
$countries[] = 'Wake Island (+1 808)';
$countries[] = 'Wallis and Futuna (+681)';
$countries[] = 'Yemen (+967)';
$countries[] = 'Zambia (+260)';
$countries[] = 'Zanzibar (+255)';
$countries[] = 'Zimbabwe (+263)';
?>
$country = $countries[$formData['countryCode']];
switch ($country)
{
case 'United States (+1)':
$countryCode = 1;
break;
case 'China (+86)':
$countryCode = 86;
break;
case 'France (+33)':
$countryCode = 33;
break;
case 'Germany (+49)':
$countryCode = 49;
break;
case 'India (+91)':
$countryCode = 91;
break;
case 'Japan (+81)':
$countryCode = 81;
break;
case 'Pakistan (+92)':
$countryCode = 92;
break;
case 'United Kingdom (+44)':
$countryCode = 44;
break;
case 'Abkhazia (+7 840)':
$countryCode = 7840;
break;
case 'Abkhazia (+7 940)':
$countryCode = 7940;
break;
case 'Afghanistan (+93)':
$countryCode = 93;
break;
case 'Albania (+355)':
$countryCode = 355;
break;
case 'Algeria (+213)':
$countryCode = 213;
break;
case 'American Samoa (+1 684)':
$countryCode = 1684;
break;
case 'Andorra (+376)':
$countryCode = 376;
break;
case 'Angola (+244)':
$countryCode = 244;
break;
case 'Anguilla (+1 264)':
$countryCode = 1624;
break;
case 'Barbuda (+1 268)':
$countryCode = 1268;
break;
case 'Argentina (+54)':
$countryCode = 54;
break;
case 'Armenia (+374)':
$countryCode = 374;
break;
case 'Aruba (+297)':
$countryCode = 297;
break;
case 'Ascension (+247)':
$countryCode = 247;
break;
case 'Cocos-Keeling Islands (+61)':
$countryCode = 61;
break;
case 'Norfolk Island (+672)':
$countryCode = 672;
break;
case 'Austria (+43)':
$countryCode = 43;
break;
case 'Azerbaijan (+994)':
$countryCode = 994;
break;
case 'Bahamas (+1 242)':
$countryCode = 1242;
break;
case 'Bahrain (+973)':
$countryCode = 973;
break;
case 'Bangladesh (+880)':
$countryCode = 880;
break;
case 'Barbados (+1 246)':
$countryCode = 1246;
break;
case 'Belarus (+375)':
$countryCode = 375;
break;
case 'Belgium (+32)':
$countryCode = 32;
break;
case 'Belize (+501)':
$countryCode = 501;
break;
case 'Benin (+229)':
$countryCode = 229;
break;
case 'Bermuda (+1 441)':
$countryCode = 1441;
break;
case 'Bhutan (+975)':
$countryCode = 975;
break;
case 'Bolivia (+591)':
$countryCode = 591;
break;
case 'Bosnia and Herzegovina (+387)':
$countryCode = 387;
break;
case 'Botswana (+267)':
$countryCode = 267;
break;
case 'Brazil (+55)':
$countryCode = 55;
break;
case 'Diego Garcia (+246)':
$countryCode = 246;
break;
case 'British Virgin Islands (+1 284)':
$countryCode = 1284;
break;
case 'Brunei (+673)':
$countryCode = 673;
break;
case 'Bulgaria (+359)':
$countryCode = 359;
break;
case 'Burkina Faso (+226)':
$countryCode = 226;
break;
case 'Burundi (+257)':
$countryCode = 257;
break;
case 'Cambodia (+855)':
$countryCode = 855;
break;
case 'Cameroon (+237)':
$countryCode = 237;
break;
case 'Cape Verde (+238)':
$countryCode = 238;
break;
case 'Cayman Islands (+ 345)':
$countryCode = 1345;
break;
case 'Central African Republic (+236)':
$countryCode = 236;
break;
case 'Chad (+235)':
$countryCode = 235;
break;
case 'Easter Island (+56)':
$countryCode = 56;
break;
case 'Colombia (+57)':
$countryCode = 57;
break;
case 'Comoros (+269)':
$countryCode = 269;
break;
case 'Congo (+242)':
$countryCode = 242;
break;
case 'Congo, Dem. Rep. of (Zaire) (+243)':
$countryCode = 243;
break;
case 'Cook Islands (+682)':
$countryCode = 682;
break;
case 'Costa Rica (+506)':
$countryCode = 506;
break;
case 'Ivory Coast (+225)':
$countryCode = 225;
break;
case 'Croatia (+385)':
$countryCode = 385;
break;
case 'Cuba (+53)':
$countryCode = 53;
break;
case 'Netherlands Antilles (+599)':
$countryCode = 599;
break;
case 'Cyprus (+537)':
$countryCode = 537;
break;
case 'Czech Republic (+420)':
$countryCode = 420;
break;
case 'Denmark (+45)':
$countryCode = 45;
break;
case 'Djibouti (+253)':
$countryCode = 253;
break;
case 'Dominica (+1 767)':
$countryCode = 1767;
break;
case 'Dominican Republic (+1 809)':
$countryCode = 1809;
break;
case 'Dominican Republic (+1 829)':
$countryCode = 1829;
break;
case 'Dominican Republic (+1 849)':
$countryCode = 1849;
break;
case 'Timor Leste (+670)':
$countryCode = 670;
break;
case 'Ecuador (+593)':
$countryCode = 593;
break;
case 'Egypt (+20)':
$countryCode = 20;
break;
case 'El Salvador (+503)':
$countryCode = 503;
break;
case 'Equatorial Guinea (+240)':
$countryCode = 240;
break;
case 'Eritrea (+291)':
$countryCode = 291;
break;
case 'Estonia (+372)':
$countryCode = 372;
break;
case 'Ethiopia (+251)':
$countryCode = 251;
break;
case 'South Georgia and the South Sandwich Islands (+500)':
$countryCode = 500;
break;
case 'Faroe Islands (+298)':
$countryCode = 298;
break;
case 'Fiji (+679)':
$countryCode = 679;
break;
case 'Finland (+358)':
$countryCode = 358;
break;
case 'Martinique (+596)':
$countryCode = 596;
break;
case 'French Guiana (+594)':
$countryCode = 594;
break;
case 'French Polynesia (+689)':
$countryCode = 689;
break;
case 'Gabon (+241)':
$countryCode = 241;
break;
case 'Gambia (+220)':
$countryCode = 220;
break;
case 'Georgia (+995)':
$countryCode = 995;
break;
case 'Ghana (+233)':
$countryCode = 233;
break;
case 'Gibraltar (+350)':
$countryCode = 350;
break;
case 'Greece (+30)':
$countryCode = 30;
break;
case 'Greenland (+299)':
$countryCode = 299;
break;
case 'Grenada (+1 473)':
$countryCode = 1473;
break;
case 'Guadeloupe (+590)':
$countryCode = 590;
break;
case 'Guam (+1 671)':
$countryCode = 1671;
break;
case 'Guatemala (+502)':
$countryCode = 502;
break;
case 'Guinea (+224)':
$countryCode = 224;
break;
case 'Guinea-Bissau (+245)':
$countryCode = 245;
break;
case 'Guyana (+595)':
$countryCode = 592;
break;
case 'Haiti (+509)':
$countryCode = 509;
break;
case 'Honduras (+504)':
$countryCode = 504;
break;
case 'Hong Kong SAR China (+852)':
$countryCode = 852;
break;
case 'Hungary (+36)':
$countryCode = 36;
break;
case 'Iceland (+354)':
$countryCode = 354;
break;
case 'Indonesia (+62)':
$countryCode = 62;
break;
case 'Iran (+98)':
$countryCode = 98;
break;
case 'Iraq (+964)':
$countryCode = 964;
break;
case 'Ireland (+353)':
$countryCode = 353;
break;
case 'Israel (+972)':
$countryCode = 972;
break;
case 'Italy (+39)':
$countryCode = 39;
break;
case 'Jamaica (+1 876)':
$countryCode = 1876;
break;
case 'Jordan (+962)':
$countryCode = 962;
break;
case 'Kazakhstan (+7 7)':
$countryCode = 77;
break;
case 'Kenya (+254)':
$countryCode = 254;
break;
case 'Kiribati (+686)':
$countryCode = 686;
break;
case 'North Korea (+850)':
$countryCode = 850;
break;
case 'South Korea (+82)':
$countryCode = 82;
break;
case 'Kuwait (+965)':
$countryCode = 965;
break;
case 'Kyrgyzstan (+996)':
$countryCode = 996;
break;
case 'Laos (+856)':
$countryCode = 856;
break;
case 'Latvia (+371)':
$countryCode = 371;
break;
case 'Lebanon (+961)':
$countryCode = 961;
break;
case 'Lesotho (+266)':
$countryCode = 266;
break;
case 'Liberia (+231)':
$countryCode = 231;
break;
case 'Libya (+218)':
$countryCode = 218;
break;
case 'Liechtenstein (+423)':
$countryCode = 423;
break;
case 'Lithuania (+370)':
$countryCode = 370;
break;
case 'Luxembourg (+352)':
$countryCode = 352;
break;
case 'Macau SAR China (+853)':
$countryCode = 853;
break;
case 'Macedonia (+389)':
$countryCode = 389;
break;
case 'Madagascar (+261)':
$countryCode = 261;
break;
case 'Malawi (+265)':
$countryCode = 265;
break;
case 'Malaysia (+60)':
$countryCode = 60;
break;
case 'Maldives (+960)':
$countryCode = 960;
break;
case 'Mayotte (+262)':
$countryCode = 223;
break;
case 'Malta (+356)':
$countryCode = 356;
break;
case 'Marshall Islands (+692)':
$countryCode = 692;
break;
case 'Mauritania (+222)':
$countryCode = 222;
break;
case 'Mauritius (+230)':
$countryCode = 230;
break;
case 'Mexico (+52)':
$countryCode = 52;
break;
case 'Micronesia (+691)':
$countryCode = 691;
break;
case 'Wake Island (+1 808)':
$countryCode = 1808;
break;
case 'Moldova (+373)':
$countryCode = 373;
break;
case 'Monaco (+377)':
$countryCode = 377;
break;
case 'Mongolia (+976)':
$countryCode = 976;
break;
case 'Montenegro (+382)':
$countryCode = 382;
break;
case 'Montserrat (+1664)':
$countryCode = 1664;
break;
case 'Morocco (+212)':
$countryCode = 212;
break;
case 'Myanmar (+95)':
$countryCode = 95;
break;
case 'Namibia (+264)':
$countryCode = 264;
break;
case 'Nauru (+674)':
$countryCode = 674;
break;
case 'Nepal (+977)':
$countryCode = 977;
break;
case 'Netherlands (+31)':
$countryCode = 31;
break;
case 'Nevis (+1 869)':
$countryCode = 1869;
break;
case 'New Caledonia (+687)':
$countryCode = 687;
break;
case 'New Zealand (64)':
$countryCode = 64;
break;
case 'Nicaragua (+505)':
$countryCode = 505;
break;
case 'Niger (+227)':
$countryCode = 227;
break;
case 'Nigeria (+234)':
$countryCode = 234;
break;
case 'Niue (+683)':
$countryCode = 683;
break;
case 'Northern Mariana Islands (+1 670)':
$countryCode = 1670;
break;
case 'Norway (+47)':
$countryCode = 47;
break;
case 'Oman (+968)':
$countryCode = 968;
break;
case 'Palau (+680)':
$countryCode = 680;
break;
case 'Palestinian Territory (+970)':
$countryCode = 970;
break;
case 'Panama (+507)':
$countryCode = 507;
break;
case 'Papua New Guinea (+675)':
$countryCode = 675;
break;
case 'Paraguay (+595)':
$countryCode = 595;
break;
case 'Peru (+51)':
$countryCode = 51;
break;
case 'Philippines (+63)':
$countryCode = 63;
break;
case 'Poland (+48)':
$countryCode = 48;
break;
case 'Portugal (+351)':
$countryCode = 351;
break;
case 'Puerto Rico (+1 787)':
$countryCode = 1787;
break;
case 'Puerto Rico (+1 939)':
$countryCode = 1939;
break;
case 'Qatar (+974)':
$countryCode = 974;
break;
case 'Reunion (+262)':
$countryCode = 262;
break;
case 'Romania (+40)':
$countryCode = 40;
break;
case 'Russia (+7)':
$countryCode = 7;
break;
case 'Rwanda (+250)':
$countryCode = 250;
break;
case 'Samoa (+685)':
$countryCode = 685;
break;
case 'San Marino (+378)':
$countryCode = 378;
break;
case 'Saudi Arabia (+966)':
$countryCode = 966;
break;
case 'Senegal (+221)':
$countryCode = 221;
break;
case 'Serbia (+381)':
$countryCode = 381;
break;
case 'Seychelles (+248)':
$countryCode = 248;
break;
case 'Sierra Leone (+232)':
$countryCode = 232;
break;
case 'Singapore (+65)':
$countryCode = 65;
break;
case 'Slovakia (+421)':
$countryCode = 421;
break;
case 'Slovenia (+386)':
$countryCode = 386;
break;
case 'Solomon Islands (+677)':
$countryCode = 677;
break;
case 'South Africa (+27)':
$countryCode = 27;
break;
case 'Spain (+34)':
$countryCode = 34;
break;
case 'Sri Lanka (+94)':
$countryCode = 94;
break;
case 'Sudan (+249)':
$countryCode = 249;
break;
case 'Suriname (+597)':
$countryCode = 597;
break;
case 'Swaziland (+268)':
$countryCode = 268;
break;
case 'Sweden (+46)':
$countryCode = 46;
break;
case 'Switzerland (+41)':
$countryCode = 41;
break;
case 'Syria (+963)':
$countryCode = 963;
break;
case 'Taiwan (+886)':
$countryCode = 886;
break;
case 'Tajikistan (+992)':
$countryCode = 992;
break;
case 'Zanzibar (+255)':
$countryCode = 255;
break;
case 'Thailand (+66)':
$countryCode = 66;
break;
case 'Togo (+228)':
$countryCode = 228;
break;
case 'Tokelau (+690)':
$countryCode = 690;
break;
case 'Tonga (+676)':
$countryCode = 676;
break;
case 'Trinidad and Tobago (+1 868)':
$countryCode = 1868;
break;
case 'Tunisia (+216)':
$countryCode = 216;
break;
case 'Turkey (+90)':
$countryCode = 90;
break;
case 'Turkmenistan (+993)':
$countryCode = 993;
break;
case 'Turks and Caicos Islands (+1 649)':
$countryCode = 1649;
break;
case 'Tuvalu (+688)':
$countryCode = 688;
break;
case 'Uganda (+256)':
$countryCode = 256;
break;
case 'Ukraine (+380)':
$countryCode = 380;
break;
case 'United Arab Emirates (+971)':
$countryCode = 971;
break;
case 'Uruguay (+598)':
$countryCode = 598;
break;
case 'U.S. Virgin Islands (+1 340)':
$countryCode = 1340;
break;
case 'Uzbekistan (+998)':
$countryCode = 998;
break;
case 'Vanuatu (+678)':
$countryCode = 678;
break;
case 'Venezuela (+58)':
$countryCode = 58;
break;
case 'Vietnam (+84)':
$countryCode = 84;
break;
case 'Wallis and Futuna (+681)':
$countryCode = 681;
break;
case 'Yemen (+967)':
$countryCode = 967;
break;
case 'Zambia (+260)':
$countryCode = 260;
break;
case 'Zimbabwe (+263)':
$countryCode = 263;
break;
default:
$countryCode = 1; // Shouldn't really ever happen
break;
}
<select name="countryCode" id="countryCode">
<option value="1" label="Canada (+1)">Canada (+1)</option>
<option value="2" label="China (+86)">China (+86)</option>
<option value="3" label="France (+33)">France (+33)</option>
<option value="4" label="Germany (+49)">Germany (+49)</option>
<option value="5" label="India (+91)">India (+91)</option>
<option value="6" label="Japan (+81)">Japan (+81)</option>
<option value="7" label="Pakistan (+92)">Pakistan (+92)</option>
<option value="8" label="United Kingdom (+44)">United Kingdom (+44)</option>
<option value="9" label="United States (+1)">United States (+1)</option>
<option value="10" label="--">--</option>
<option value="11" label="Abkhazia (+7 840)">Abkhazia (+7 840)</option>
<option value="12" label="Abkhazia (+7 940)">Abkhazia (+7 940)</option>
<option value="13" label="Afghanistan (+93)">Afghanistan (+93)</option>
<option value="14" label="Albania (+355)">Albania (+355)</option>
<option value="15" label="Algeria (+213)">Algeria (+213)</option>
<option value="16" label="American Samoa (+1 684)">American Samoa (+1 684)</option>
<option value="17" label="Andorra (+376)">Andorra (+376)</option>
<option value="18" label="Angola (+244)">Angola (+244)</option>
<option value="19" label="Anguilla (+1 264)">Anguilla (+1 264)</option>
<option value="20" label="Antigua and Barbuda (+1 268)">Antigua and Barbuda (+1 268)</option>
<option value="21" label="Argentina (+54)">Argentina (+54)</option>
<option value="22" label="Armenia (+374)">Armenia (+374)</option>
<option value="23" label="Aruba (+297)">Aruba (+297)</option>
<option value="24" label="Ascension (+247)">Ascension (+247)</option>
<option value="25" label="Australia (+61)">Australia (+61)</option>
<option value="26" label="Australian External Territories (+672)">Australian External Territories (+672)</option>
<option value="27" label="Austria (+43)">Austria (+43)</option>
<option value="28" label="Azerbaijan (+994)">Azerbaijan (+994)</option>
<option value="29" label="Bahamas (+1 242)">Bahamas (+1 242)</option>
<option value="30" label="Bahrain (+973)">Bahrain (+973)</option>
<option value="31" label="Bangladesh (+880)">Bangladesh (+880)</option>
<option value="32" label="Barbados (+1 246)">Barbados (+1 246)</option>
<option value="33" label="Barbuda (+1 268)">Barbuda (+1 268)</option>
<option value="34" label="Belarus (+375)">Belarus (+375)</option>
<option value="35" label="Belgium (+32)">Belgium (+32)</option>
<option value="36" label="Belize (+501)">Belize (+501)</option>
<option value="37" label="Benin (+229)">Benin (+229)</option>
<option value="38" label="Bermuda (+1 441)">Bermuda (+1 441)</option>
<option value="39" label="Bhutan (+975)">Bhutan (+975)</option>
<option value="40" label="Bolivia (+591)">Bolivia (+591)</option>
<option value="41" label="Bosnia and Herzegovina (+387)">Bosnia and Herzegovina (+387)</option>
<option value="42" label="Botswana (+267)">Botswana (+267)</option>
<option value="43" label="Brazil (+55)">Brazil (+55)</option>
<option value="44" label="British Indian Ocean Territory (+246)">British Indian Ocean Territory (+246)</option>
<option value="45" label="British Virgin Islands (+1 284)">British Virgin Islands (+1 284)</option>
<option value="46" label="Brunei (+673)">Brunei (+673)</option>
<option value="47" label="Bulgaria (+359)">Bulgaria (+359)</option>
<option value="48" label="Burkina Faso (+226)">Burkina Faso (+226)</option>
<option value="49" label="Burundi (+257)">Burundi (+257)</option>
<option value="50" label="Cambodia (+855)">Cambodia (+855)</option>
<option value="51" label="Cameroon (+237)">Cameroon (+237)</option>
<option value="52" label="Canada (+1)">Canada (+1)</option>
<option value="53" label="Cape Verde (+238)">Cape Verde (+238)</option>
<option value="54" label="Cayman Islands (+ 345)">Cayman Islands (+ 345)</option>
<option value="55" label="Central African Republic (+236)">Central African Republic (+236)</option>
<option value="56" label="Chad (+235)">Chad (+235)</option>
<option value="57" label="Chile (+56)">Chile (+56)</option>
<option value="58" label="China (+86)">China (+86)</option>
<option value="59" label="Christmas Island (+61)">Christmas Island (+61)</option>
<option value="60" label="Cocos-Keeling Islands (+61)">Cocos-Keeling Islands (+61)</option>
<option value="61" label="Colombia (+57)">Colombia (+57)</option>
<option value="62" label="Comoros (+269)">Comoros (+269)</option>
<option value="63" label="Congo (+242)">Congo (+242)</option>
<option value="64" label="Congo, Dem. Rep. of (Zaire) (+243)">Congo, Dem. Rep. of (Zaire) (+243)</option>
<option value="65" label="Cook Islands (+682)">Cook Islands (+682)</option>
<option value="66" label="Costa Rica (+506)">Costa Rica (+506)</option>
<option value="67" label="Ivory Coast (+225)">Ivory Coast (+225)</option>
<option value="68" label="Croatia (+385)">Croatia (+385)</option>
<option value="69" label="Cuba (+53)">Cuba (+53)</option>
<option value="70" label="Curacao (+599)">Curacao (+599)</option>
<option value="71" label="Cyprus (+537)">Cyprus (+537)</option>
<option value="72" label="Czech Republic (+420)">Czech Republic (+420)</option>
<option value="73" label="Denmark (+45)">Denmark (+45)</option>
<option value="74" label="Diego Garcia (+246)">Diego Garcia (+246)</option>
<option value="75" label="Djibouti (+253)">Djibouti (+253)</option>
<option value="76" label="Dominica (+1 767)">Dominica (+1 767)</option>
<option value="77" label="Dominican Republic (+1 809)">Dominican Republic (+1 809)</option>
<option value="78" label="Dominican Republic (+1 829)">Dominican Republic (+1 829)</option>
<option value="79" label="Dominican Republic (+1 849)">Dominican Republic (+1 849)</option>
<option value="80" label="East Timor (+670)">East Timor (+670)</option>
<option value="81" label="Easter Island (+56)">Easter Island (+56)</option>
<option value="82" label="Ecuador (+593)">Ecuador (+593)</option>
<option value="83" label="Egypt (+20)">Egypt (+20)</option>
<option value="84" label="El Salvador (+503)">El Salvador (+503)</option>
<option value="85" label="Equatorial Guinea (+240)">Equatorial Guinea (+240)</option>
<option value="86" label="Eritrea (+291)">Eritrea (+291)</option>
<option value="87" label="Estonia (+372)">Estonia (+372)</option>
<option value="88" label="Ethiopia (+251)">Ethiopia (+251)</option>
<option value="89" label="Falkland Islands (+500)">Falkland Islands (+500)</option>
<option value="90" label="Faroe Islands (+298)">Faroe Islands (+298)</option>
<option value="91" label="Fiji (+679)">Fiji (+679)</option>
<option value="92" label="Finland (+358)">Finland (+358)</option>
<option value="93" label="France (+33)">France (+33)</option>
<option value="94" label="French Antilles (+596)">French Antilles (+596)</option>
<option value="95" label="French Guiana (+594)">French Guiana (+594)</option>
<option value="96" label="French Polynesia (+689)">French Polynesia (+689)</option>
<option value="97" label="Gabon (+241)">Gabon (+241)</option>
<option value="98" label="Gambia (+220)">Gambia (+220)</option>
<option value="99" label="Georgia (+995)">Georgia (+995)</option>
<option value="100" label="Germany (+49)">Germany (+49)</option>
<option value="101" label="Ghana (+233)">Ghana (+233)</option>
<option value="102" label="Gibraltar (+350)">Gibraltar (+350)</option>
<option value="103" label="Greece (+30)">Greece (+30)</option>
<option value="104" label="Greenland (+299)">Greenland (+299)</option>
<option value="105" label="Grenada (+1 473)">Grenada (+1 473)</option>
<option value="106" label="Guadeloupe (+590)">Guadeloupe (+590)</option>
<option value="107" label="Guam (+1 671)">Guam (+1 671)</option>
<option value="108" label="Guatemala (+502)">Guatemala (+502)</option>
<option value="109" label="Guinea (+224)">Guinea (+224)</option>
<option value="110" label="Guinea-Bissau (+245)">Guinea-Bissau (+245)</option>
<option value="111" label="Guyana (+595)">Guyana (+595)</option>
<option value="112" label="Haiti (+509)">Haiti (+509)</option>
<option value="113" label="Honduras (+504)">Honduras (+504)</option>
<option value="114" label="Hong Kong SAR China (+852)">Hong Kong SAR China (+852)</option>
<option value="115" label="Hungary (+36)">Hungary (+36)</option>
<option value="116" label="Iceland (+354)">Iceland (+354)</option>
<option value="117" label="India (+91)">India (+91)</option>
<option value="118" label="Indonesia (+62)">Indonesia (+62)</option>
<option value="119" label="Iran (+98)">Iran (+98)</option>
<option value="120" label="Iraq (+964)">Iraq (+964)</option>
<option value="121" label="Ireland (+353)">Ireland (+353)</option>
<option value="122" label="Israel (+972)">Israel (+972)</option>
<option value="123" label="Italy (+39)">Italy (+39)</option>
<option value="124" label="Jamaica (+1 876)">Jamaica (+1 876)</option>
<option value="125" label="Japan (+81)">Japan (+81)</option>
<option value="126" label="Jordan (+962)">Jordan (+962)</option>
<option value="127" label="Kazakhstan (+7 7)">Kazakhstan (+7 7)</option>
<option value="128" label="Kenya (+254)">Kenya (+254)</option>
<option value="129" label="Kiribati (+686)">Kiribati (+686)</option>
<option value="130" label="North Korea (+850)">North Korea (+850)</option>
<option value="131" label="South Korea (+82)">South Korea (+82)</option>
<option value="132" label="Kuwait (+965)">Kuwait (+965)</option>
<option value="133" label="Kyrgyzstan (+996)">Kyrgyzstan (+996)</option>
<option value="134" label="Laos (+856)">Laos (+856)</option>
<option value="135" label="Latvia (+371)">Latvia (+371)</option>
<option value="136" label="Lebanon (+961)">Lebanon (+961)</option>
<option value="137" label="Lesotho (+266)">Lesotho (+266)</option>
<option value="138" label="Liberia (+231)">Liberia (+231)</option>
<option value="139" label="Libya (+218)">Libya (+218)</option>
<option value="140" label="Liechtenstein (+423)">Liechtenstein (+423)</option>
<option value="141" label="Lithuania (+370)">Lithuania (+370)</option>
<option value="142" label="Luxembourg (+352)">Luxembourg (+352)</option>
<option value="143" label="Macau SAR China (+853)">Macau SAR China (+853)</option>
<option value="144" label="Macedonia (+389)">Macedonia (+389)</option>
<option value="145" label="Madagascar (+261)">Madagascar (+261)</option>
<option value="146" label="Malawi (+265)">Malawi (+265)</option>
<option value="147" label="Malaysia (+60)">Malaysia (+60)</option>
<option value="148" label="Maldives (+960)">Maldives (+960)</option>
<option value="149" label="Mali (+223)">Mali (+223)</option>
<option value="150" label="Malta (+356)">Malta (+356)</option>
<option value="151" label="Marshall Islands (+692)">Marshall Islands (+692)</option>
<option value="152" label="Martinique (+596)">Martinique (+596)</option>
<option value="153" label="Mauritania (+222)">Mauritania (+222)</option>
<option value="154" label="Mauritius (+230)">Mauritius (+230)</option>
<option value="155" label="Mayotte (+262)">Mayotte (+262)</option>
<option value="156" label="Mexico (+52)">Mexico (+52)</option>
<option value="157" label="Micronesia (+691)">Micronesia (+691)</option>
<option value="158" label="Midway Island (+1 808)">Midway Island (+1 808)</option>
<option value="159" label="Micronesia (+691)">Micronesia (+691)</option>
<option value="160" label="Moldova (+373)">Moldova (+373)</option>
<option value="161" label="Monaco (+377)">Monaco (+377)</option>
<option value="162" label="Mongolia (+976)">Mongolia (+976)</option>
<option value="163" label="Montenegro (+382)">Montenegro (+382)</option>
<option value="164" label="Montserrat (+1664)">Montserrat (+1664)</option>
<option value="165" label="Morocco (+212)">Morocco (+212)</option>
<option value="166" label="Myanmar (+95)">Myanmar (+95)</option>
<option value="167" label="Namibia (+264)">Namibia (+264)</option>
<option value="168" label="Nauru (+674)">Nauru (+674)</option>
<option value="169" label="Nepal (+977)">Nepal (+977)</option>
<option value="170" label="Netherlands (+31)">Netherlands (+31)</option>
<option value="171" label="Netherlands Antilles (+599)">Netherlands Antilles (+599)</option>
<option value="172" label="Nevis (+1 869)">Nevis (+1 869)</option>
<option value="173" label="New Caledonia (+687)">New Caledonia (+687)</option>
<option value="174" label="New Zealand (64)">New Zealand (64)</option>
<option value="175" label="Nicaragua (+505)">Nicaragua (+505)</option>
<option value="176" label="Niger (+227)">Niger (+227)</option>
<option value="177" label="Nigeria (+234)">Nigeria (+234)</option>
<option value="178" label="Niue (+683)">Niue (+683)</option>
<option value="179" label="Norfolk Island (+672)">Norfolk Island (+672)</option>
<option value="180" label="Northern Mariana Islands (+1 670)">Northern Mariana Islands (+1 670)</option>
<option value="181" label="Norway (+47)">Norway (+47)</option>
<option value="182" label="Oman (+968)">Oman (+968)</option>
<option value="183" label="Pakistan (+92)">Pakistan (+92)</option>
<option value="184" label="Palau (+680)">Palau (+680)</option>
<option value="185" label="Palestinian Territory (+970)">Palestinian Territory (+970)</option>
<option value="186" label="Panama (+507)">Panama (+507)</option>
<option value="187" label="Papua New Guinea (+675)">Papua New Guinea (+675)</option>
<option value="188" label="Paraguay (+595)">Paraguay (+595)</option>
<option value="189" label="Peru (+51)">Peru (+51)</option>
<option value="190" label="Philippines (+63)">Philippines (+63)</option>
<option value="191" label="Poland (+48)">Poland (+48)</option>
<option value="192" label="Portugal (+351)">Portugal (+351)</option>
<option value="193" label="Puerto Rico (+1 787)">Puerto Rico (+1 787)</option>
<option value="194" label="Puerto Rico (+1 939)">Puerto Rico (+1 939)</option>
<option value="195" label="Qatar (+974)">Qatar (+974)</option>
<option value="196" label="Reunion (+262)">Reunion (+262)</option>
<option value="197" label="Romania (+40)">Romania (+40)</option>
<option value="198" label="Russia (+7)">Russia (+7)</option>
<option value="199" label="Rwanda (+250)">Rwanda (+250)</option>
<option value="200" label="Samoa (+685)">Samoa (+685)</option>
<option value="201" label="San Marino (+378)">San Marino (+378)</option>
<option value="202" label="Saudi Arabia (+966)">Saudi Arabia (+966)</option>
<option value="203" label="Senegal (+221)">Senegal (+221)</option>
<option value="204" label="Serbia (+381)">Serbia (+381)</option>
<option value="205" label="Seychelles (+248)">Seychelles (+248)</option>
<option value="206" label="Sierra Leone (+232)">Sierra Leone (+232)</option>
<option value="207" label="Singapore (+65)">Singapore (+65)</option>
<option value="208" label="Slovakia (+421)">Slovakia (+421)</option>
<option value="209" label="Slovenia (+386)">Slovenia (+386)</option>
<option value="210" label="Solomon Islands (+677)">Solomon Islands (+677)</option>
<option value="211" label="South Africa (+27)">South Africa (+27)</option>
<option value="212" label="South Georgia and the South Sandwich Islands (+500)">South Georgia and the South Sandwich Islands (+500)</option>
<option value="213" label="Spain (+34)">Spain (+34)</option>
<option value="214" label="Sri Lanka (+94)">Sri Lanka (+94)</option>
<option value="215" label="Sudan (+249)">Sudan (+249)</option>
<option value="216" label="Suriname (+597)">Suriname (+597)</option>
<option value="217" label="Swaziland (+268)">Swaziland (+268)</option>
<option value="218" label="Sweden (+46)">Sweden (+46)</option>
<option value="219" label="Switzerland (+41)">Switzerland (+41)</option>
<option value="220" label="Syria (+963)">Syria (+963)</option>
<option value="221" label="Taiwan (+886)">Taiwan (+886)</option>
<option value="222" label="Tajikistan (+992)">Tajikistan (+992)</option>
<option value="223" label="Tanzania (+255)">Tanzania (+255)</option>
<option value="224" label="Thailand (+66)">Thailand (+66)</option>
<option value="225" label="Timor Leste (+670)">Timor Leste (+670)</option>
<option value="226" label="Togo (+228)">Togo (+228)</option>
<option value="227" label="Tokelau (+690)">Tokelau (+690)</option>
<option value="228" label="Tonga (+676)">Tonga (+676)</option>
<option value="229" label="Trinidad and Tobago (+1 868)">Trinidad and Tobago (+1 868)</option>
<option value="230" label="Tunisia (+216)">Tunisia (+216)</option>
<option value="231" label="Turkey (+90)">Turkey (+90)</option>
<option value="232" label="Turkmenistan (+993)">Turkmenistan (+993)</option>
<option value="233" label="Turks and Caicos Islands (+1 649)">Turks and Caicos Islands (+1 649)</option>
<option value="234" label="Tuvalu (+688)">Tuvalu (+688)</option>
<option value="235" label="Uganda (+256)">Uganda (+256)</option>
<option value="236" label="Ukraine (+380)">Ukraine (+380)</option>
<option value="237" label="United Arab Emirates (+971)">United Arab Emirates (+971)</option>
<option value="238" label="United Kingdom (+44)">United Kingdom (+44)</option>
<option value="239" label="United States (+1)">United States (+1)</option>
<option value="240" label="Uruguay (+598)">Uruguay (+598)</option>
<option value="241" label="U.S. Virgin Islands (+1 340)">U.S. Virgin Islands (+1 340)</option>
<option value="242" label="Uzbekistan (+998)">Uzbekistan (+998)</option>
<option value="243" label="Vanuatu (+678)">Vanuatu (+678)</option>
<option value="244" label="Venezuela (+58)">Venezuela (+58)</option>
<option value="245" label="Vietnam (+84)">Vietnam (+84)</option>
<option value="246" label="Wake Island (+1 808)">Wake Island (+1 808)</option>
<option value="247" label="Wallis and Futuna (+681)">Wallis and Futuna (+681)</option>
<option value="248" label="Yemen (+967)">Yemen (+967)</option>
<option value="249" label="Zambia (+260)">Zambia (+260)</option>
<option value="250" label="Zanzibar (+255)">Zanzibar (+255)</option>
<option value="251" label="Zimbabwe (+263)">Zimbabwe (+263)</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment