Drop down default current country

More
4 years 3 weeks ago #101301 by emimarz
emimarz created the topic: Drop down default current country
Well, the title explain all. I need do a drop down and put as default the current country.

Is it possible?

thanks in advance
Emiliano

Please Log in to join the conversation.

More
4 years 2 weeks ago - 4 years 2 weeks ago #101364 by emimarz
emimarz replied the topic: Drop down default current country
Ready I do it.

There is the solution if somebody need it

on template survey I add a input and the following JS
<input id="country-code" type="hidden" />
<script>
    $(document).ready(function(){
      if($("#idoftheselect").length==1){
        jQuery.getJSON('http://freegeoip.net/json/', function(location) {
          $('#country-code').val(location.country_code);
          $("#idoftheselect [value="+location.country_code+"]").attr("selected", true);
        });
      }
    });
  </script>

The drop down will need the next format
id = code 2 characters following the iso 3166-1
here you have a reference
en.wikipedia.org/ISO_3166-1

I hope be helpful
if somebody need help please answer to this topic

Best
Emiliano
Last Edit: 4 years 2 weeks ago by DenisChenu. Reason: code
The following user(s) said Thank You: DenisChenu, tpartner, Ben_V

Please Log in to join the conversation.

More
4 years 2 weeks ago #101381 by DenisChenu
DenisChenu replied the topic: Drop down default current country
Hi,

Thanks, it's a great information here !

Maybe a good system for
- WorkAround on wiki
- New attribute and/or question type dor 2.1 LS release

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!