![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/clinic.corals.io/node_modules/intl-tel-input/examples/js/ |
// get the country data from the plugin var countryData = window.intlTelInputGlobals.getCountryData(), input = document.querySelector("#phone"), addressDropdown = document.querySelector("#address-country"); // init plugin var iti = window.intlTelInput(input, { utilsScript: "../../build/js/utils.js?<%= time %>" // just for formatting/placeholders etc }); // populate the country dropdown for (var i = 0; i < countryData.length; i++) { var country = countryData[i]; var optionNode = document.createElement("option"); optionNode.value = country.iso2; var textNode = document.createTextNode(country.name); optionNode.appendChild(textNode); addressDropdown.appendChild(optionNode); } // set it's initial value addressDropdown.value = iti.getSelectedCountryData().iso2; // listen to the telephone input for changes input.addEventListener('countrychange', function(e) { addressDropdown.value = iti.getSelectedCountryData().iso2; }); // listen to the address dropdown for changes addressDropdown.addEventListener('change', function() { iti.setCountry(this.value); });