- Posts: 8
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Array with first text and then with radiolist
- RomTav
- Topic Author
- Offline
- New Member
Your LimeSurvey version: Version 5.2.5
Own server or LimeSurvey hosting: LimeSurvey hosting
Theme: fruity
==================
Hello,
Is it possible to create an array starting with 3 text columns and finishing with 5-choice radiolists?
I adapted a .lsg code doing the other way round (starting with radiolist) and managed to add a second text column:
I could not find a way to reorder the array for it to start with the text field. I tried to use the function ".prepend()" instead of ".append()" but the subquestions' titles were then placed on the middle of the array:
Do you know how I could either hide the subquestions column or reorder the array for it to start with text fields?
You can find attached the .lsg code for "test1.png" :
Thanks in advance !
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12940
- Thank you received: 3979
lsq and lsg exports are language sensitive. (You can't import them into a survey with different base language)
An alternative is to use a drop-down instead of radio buttons.
Like this (additionally with different column widths)
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- RomTav
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 0
As we need to create an online survey that corresponds as much as we can to the format used on paper (not editable), do you know if keeping radiolist instead of dropdown menu could be feasible?
If not, the solution you proposed is a good alternative and we could go on with it !
Best regards,
Romane
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10109
- Thank you received: 3595
As Joffm suggests, attach a small sample survey (.lss file) containing only the relevant questions.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- RomTav
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 0
You can find attached the file .lss with the three tests undertaken, I hope this could help.
The desire format is the following:
The alternative given by Joffm can answer our need as it gathered all the information required and in the good order.
To be consistent with the format from the paper questionnaire (as in the picture just above), I was wondering if it is possible to create a table with first 3 columns of texts and then 5 columns of radio buttons.
Thank you in advance,
Romane
Please Log in to join the conversation.
- holch
- Offline
- LimeSurvey Community Team
- Posts: 11660
- Thank you received: 2742
Probably the most common mistake ever made when it comes to digitalizing questionnaires.As we need to create an online survey that corresponds as much as we can to the format used on paper (not editable),
I understand why some people are concerned of changing the way of a questionnaire, but you are already changing it a bit by moving it online, you might as well go all the way and make a clean cut. At least that is my philosophy. Because if you don't do it now, you will never do it and always get stuck with a suboptimal online questionnaire.
And then there is the issue of mobile, where these approaches won't work anyway and you will have to adapt. So now you have those that fill the questionnaire on a big screen the "traditional" way (more or less, because it is already different anyway) and then you have those that fill it on a mobile device (and their number is growing) and they will have a completely different experience.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10109
- Thank you received: 3595
I could not find a way to reorder the array for it to start with the text field. I tried to use the function ".prepend()" instead of ".append()" but the subquestions' titles were then placed on the middle of the array:
You cannot simply use prepend() because the first cells in each row must remain in place. You will need to use after().
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var qArrayID = {QID}; var qArray = $('#question'+qArrayID); var qMultiText = qArray.nextAll('.multiple-short-txt:eq(0)'); var qMultiTextBis = qMultiText.nextAll('.multiple-short-txt:eq(0)'); // Hide the multi-short-text question $(qMultiText).hide(); $(qMultiTextBis).hide(); // Remove the core column widths $('table.questions-list col:not(.col-answers)', qArray).css('width', 'auto'); // Insert the header cells $('table.questions-list thead td:eq(0)', qArray).after('<th class="answer-text inserted-column-label" /></th><th class="answer-text-bis inserted-column-label-bis" /></th>'); $('.inserted-column-label, .inserted-column-label-bis', qArray).css('width','30%'); // Insert the answer row cells $('tr.answers-list', qArray).each(function(i) { $('.answertext', this).after('<td class="answer-item text-item"></td><td class="answer-item text-item-bis"></td>'); }); // Load the column label for the text inputs $('.inserted-column-label:eq(0)', qArray).text($('.ls-label-question', qMultiText).text()); $('.inserted-column-label-bis:eq(0)', qArray).text($('.ls-label-question', qMultiTextBis).text()); // Loop through the multi-short-text sub-questions $('li.answer-item', qMultiText).each(function(i) { // Move the text inputs into the array $('input[type="text"]', this).appendTo($('tr.answers-list:eq('+i+') .text-item', qArray)); }); $('li.answer-item', qMultiTextBis).each(function(i) { // Move the text inputs into the array $('input[type="text"]', this).appendTo($('tr.answers-list:eq('+i+') .text-item-bis', qArray)); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- RomTav
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 0
Please Log in to join the conversation.
- mt9999
- Offline
- Junior Member
- Posts: 24
- Thank you received: 0
I'm trying to do something similar but am having trouble adapting this code for my question as I have one column for text input and 4 rows of multiple choice responses (participants can choose more than one of these options). Would you be able to help with this?
I'm also trying to enter this into a dual scale array as I'd like one side to have a header though I'm assuming no easy way to remove the top header on the left side of the dual array scale (as seen in attached image). I'm still trying to find a workaround to allow participants to enter a checkbox and text if they choose Other as well.
Thank you for any assistance!
EDIT I'm using version 5.2.13, fruity theme and hosted on LimeSurvey
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12940
- Thank you received: 3979
do it the other way.
An array(text) where you insert checkboxes.
Like this
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Column-specific classes $('tr.subquestion-list', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); // Insert checkboxes $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('custom-checkbox-item'); $('.custom-checkbox-item', thisQuestion).each(function(i) { var thisID = $('input:text:eq(0)', this).attr('id'); $('label', this).before('<input class="" id="'+thisID+'" value="Y" type="checkbox" name="'+thisID.replace(/answer/, '')+'" />'); if($('input:text:eq(0)', this).val() == 'Y') { $('input:checkbox:eq(0)', this).prop('checked', true); } $(this).removeClass('text-item').addClass('checkbox-item'); $('input:text:eq(0)', this).remove(); }); // Identify exclusive items $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-5, .answer-item.column-6', thisQuestion).addClass('non-exclusive-item'); $('.answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('exclusive-item'); // Listeners for exclusive items $('.non-exclusive-item input:checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { $(this).closest('tr.subquestion-list').find('.exclusive-item input:checkbox').prop('checked', false); } }); $('.non-exclusive-item input:text', thisQuestion).on('keyup change', function(e) { if($.trim($(this).val()) != '') { $(this).closest('tr.subquestion-list').find('.exclusive-item input:checkbox').prop('checked', false); } }); $('.exclusive-item input:checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { var thisItem = $(this).closest('.answer-item'); $(this).closest('tr.subquestion-list').find('.answer-item').not(thisItem).find('input:checkbox').prop('checked', false); $(this).closest('tr.subquestion-list').find('input:text').val(''); } }); }); </script>
And the different column width:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Add a question class thisQuestion.addClass('custom-array'); // Column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); }); </script>
<style type="text/css">.custom-array table.subquestion-list col {width: auto !important;}.custom-array table.subquestion-list thead .column-0 { width: 16%; } .custom-array table.subquestion-list thead .column-1 { width: 7%; } .custom-array table.subquestion-list thead .column-2 { width: 7%; } .custom-array table.subquestion-list thead .column-3 { width: 7%; } .custom-array table.subquestion-list thead .column-4 { width: 7%; } .custom-array table.subquestion-list thead .column-5 { width: 21%; } .custom-array table.subquestion-list thead .column-6 { width: 21%; } .custom-array table.subquestion-list thead .column-7 { width: 7%; } .custom-array table.subquestion-list thead .column-8 { width: 7%; }</style>
And there are many examples here to have this additional header.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- Malak_khashoqji
- Offline
- New Member
- Posts: 7
- Thank you received: 0
what I'm trying to do is as described in the picture
and the value of the checkboxes related to the values of the rows
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12940
- Thank you received: 3979
Okay.
1. I thought you'd like to have one checkbox and two text fields.
But I see only two items on the x-scale
2. I wrote "Adapt the script". You did not.
Didn't you see this line in the script?
// Insert checkboxes $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('custom-checkbox-item');
Remove what is not needed.
Furthermore I wrote about the "exclusiveness" of checkboxes.
This you see here
// Identify exclusive items $('.answer-item.column-1, .answer-item.column-2, .answer-item.column-3, .answer-item.column-4, .answer-item.column-5, .answer-item.column-6', thisQuestion).addClass('non-exclusive-item'); $('.answer-item.column-7, .answer-item.column-8', thisQuestion).addClass('exclusive-item'); // Listeners for exclusive items
If you don't want to use it, remove. too.
But please keep the last clisong brackets.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.