Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Switching automatically across two language survey

  • jma6610
  • jma6610's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 8 months ago #204101 by jma6610
I have a two language survey that's intended to be administered in two different countries. I'm hoping to be able to ask an initial question about the current country of residence and then switch the survey version based upon the answer instead of using the language switcher question type in Lime version 2.59. I've used javascript like that below to switch to a completely different survey, but unsure how this can be done in the easiest way. Would I have to create a second initial survey, find the correct country and then direct participants to the multilanguage second survey?

<script type="text/javascript">
window.location.href = "https://XXXXXXXXprodls200/index.php/657484?lang=en2";
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204135 by tpartner
Why not use the language switcher question type? You could use JavaScript to change the labels in that question.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • jma6610
  • jma6610's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 8 months ago #204181 by jma6610
Can you give me an example?

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago - 3 years 8 months ago #204201 by tpartner
Place something like this in the source of the language switcher question:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
    // Define variables
    var thisQuestion = $('#question{QID}');
    var countries = {
      'en': 'Canada',
      'de': 'Deutschland'
    };
 
    // Loop through the dropdown options
    $('.answer-item select option', thisQuestion).each(function(i) {
      var thisLang = $(this).attr('value');
 
      // Modify the label
      if(countries[thisLang] !== undefined &amp;&amp; countries[thisLang] !== null) {
        $(this).text(countries[thisLang]);
      }
    });
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...5(1).lss
File Size:22 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 8 months ago by tpartner.
The topic has been locked.
  • jma6610
  • jma6610's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 8 months ago #204206 by jma6610
...looks like it's working. Thanks much.

Jeff
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose