- Posts: 43
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Switching automatically across two language survey
- jma6610
- Topic Author
- Offline
- Senior Member
Less
More
3 years 8 months ago #204101
by jma6610
Switching automatically across two language survey was created 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>
<script type="text/javascript">
window.location.href = "https://XXXXXXXXprodls200/index.php/657484?lang=en2";
</script>
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
3 years 8 months ago #204135
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Switching automatically across two language survey
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 8 months ago #204181
by jma6610
Replied by jma6610 on topic Switching automatically across two language survey
Can you give me an example?
Thanks
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
3 years 8 months ago - 3 years 8 months ago #204201
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Switching automatically across two language survey
Place something like this in the source of the language switcher question:
Sample survey attached:
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 && countries[thisLang] !== null) { $(this).text(countries[thisLang]); } }); }); </script>
Sample survey attached:
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 8 months ago #204206
by jma6610
Replied by jma6610 on topic Switching automatically across two language survey
...looks like it's working. Thanks much.
Jeff
Jeff
The topic has been locked.