How to auto populate preferredCountries from intl-tel-input with db output
PHP Snippet 1:
preferedCountries = JSON.parse(data)
iti.destroy();
iti = window.intlTelInput(input, {
separateDialCode: "true",
autoHideDialCode: "true",
autoPlaceholder: "polite",
preferredCountries: preferedCountries,
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/14.0.7/js/utils.js",
customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) {
return "e.g. " + selectedCountryPlaceholder;
}
});