flagstrap icon indicating copy to clipboard operation
flagstrap copied to clipboard

Auto select current country

Open borisNG opened this issue 7 years ago • 1 comments

is it possible to pre-select user's country based on an external ip provider like https://ipinfo.io/pricing ?

borisNG avatar Mar 17 '18 16:03 borisNG

You can get the user's country code through the following code:

$(document).ready(function () { var url = "https://ipinfo.io/country"; $.get(url, function (countryCode) { alert(countryCode); //For example show "IR" }); });

Then pass the value to the input before loading the page:

data-selected-country="IR"

Saffarnejad avatar Jun 26 '19 09:06 Saffarnejad