- Posts: 14
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Dropdown list in Array text with multiple language export?
- cindy16
- Topic Author
- Offline
- New Member
Less
More
3 years 8 months ago #204470
by cindy16
Dropdown list in Array text with multiple language export? was created by cindy16
Dear all,
I have found a code hier to add Dropdown list in a array text question type. It works great (thanks for that) and we use it in three different languages(english, chinese and russian).
Now when exporting, we need the other two languages to also be in english. Normally is not a problem, but since this is a code, only the options are still in the "original language". Is there a way to automatically translate the Dropdown list option into english when exporting? Please see example below.
Thank you in Advance for your help.
Best Regards,
Cindy
I have found a code hier to add Dropdown list in a array text question type. It works great (thanks for that) and we use it in three different languages(english, chinese and russian).
Now when exporting, we need the other two languages to also be in english. Normally is not a problem, but since this is a code, only the options are still in the "original language". Is there a way to automatically translate the Dropdown list option into english when exporting? Please see example below.
Thank you in Advance for your help.
Best Regards,
Cindy
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
3 years 8 months ago #204476
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 Dropdown list in Array text with multiple language export?
You can adjust the script so it records the drop-down option value instead of the label.
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Insert selects $('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Please choose...</option>\ <option value="1">Import</option>\ <option value="2">Export</option>\ <option value="3">Joint Venture</option>\ <option value="4">Distributorship</option>\ <option value="5">Franchise</option>\ <option value="6">Others</option>\ </select>'); $('.answer-item.answer_cell_X005', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Please choose...</option>\ <option value="1">Signed</option>\ <option value="2">Planned</option>\ </select>'); // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change'); } else { $(this).closest('.answer-item').find('input:text').val('').trigger('change'); } }); // Returning to page $('.with-select input:text', thisQuestion).each(function(i) { var thisCell = $(this).closest('.answer-item'); var inputText = $.trim($(this).val()); $('select.inserted-select', thisCell).val(inputText); }); // Clean-up styles $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: cindy16
The topic has been locked.
- cindy16
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
3 years 8 months ago #204479
by cindy16
Replied by cindy16 on topic Dropdown list in Array text with multiple language export?
Wow! Thank you Tony! It works!
The topic has been locked.