Ask the community, share ideas, and connect with other LimeSurvey users!
An easier to use solution could be this plugin which doesn't require adding any custom JavaScript for having text fields at array questions: survey-consulting.com/product/array-with...t-limesurvey-plugin/Do you have permissions to insert JavaScript?
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = thisQuestion.nextAll('.text-short:eq(0)'); // Hide the next question nextQuestion.hide(); // Move the text inputs $('tr[id^="javatbd"]:last td.answertext', thisQuestion).append($('.answer-item', nextQuestion)); // Clean-up styling $('td.answertext .answer-item', thisQuestion).css({ 'padding': 0 }); $('td.answertext .answer-item div', thisQuestion).css({ 'padding': 0 }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
I'm not sure why you would want to hide/show rows in an array-by-column question. Shouldn't the answers always be shown?Hi tpartner,
Thanks again for your solutions. I came across this topic, which helped me a lot. Is there a way to modify your code so that we have a button to add more "other" lines ? Or add a "other" line if the previous one is completed ?
I am using LS community edition 5.4.x
Thank you in advance !
Best regards,
David
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)'); var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)'); var nextQuestion3 = $(thisQuestion).nextAll('.text-short:eq(2)'); var nextQuestion4 = $(thisQuestion).nextAll('.text-short:eq(3)'); var nextQuestions = $(nextQuestion1).add(nextQuestion2).add(nextQuestion3).add(nextQuestion4); var nextLength = nextQuestions.length; var sqLength = ('tr.answers-list', thisQuestion).length; // Hide the short-text questions $(nextQuestions).hide(); // Move the hidden text inputs into the array for (i = 0; i < nextLength; i++) { var workingIndex = (sqLength - 1) - (nextLength - i); var nextQ = nextQuestions[i]; $('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow'); } // Clean-up styling $('th.answertext .answer-item', thisQuestion).css({ 'padding': 0 }); $('th.answertext .answer-item div', thisQuestion).css({ 'padding': 0 }); }); </script>
Please Log in to join the conversation.