Welcome, Guest
Username: Password: Remember me

TOPIC: Drop down default current country

Drop down default current country 5 months 2 weeks ago #101301

  • emimarz
  • emimarz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Thank you received: 5
  • Karma: 1
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
The administrator has disabled public write access.

Drop down default current country 5 months 1 week ago #101364

  • emimarz
  • emimarz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 21
  • Thank you received: 5
  • Karma: 1
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: 5 months 1 week ago by DenisChenu. Reason: code
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu, tpartner, Ben_V

Drop down default current country 5 months 1 week ago #101381

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5830
  • Thank you received: 711
  • Karma: 220
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
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.101 seconds
Donation Image