- Posts: 31
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
tpartner wrote: I think the only solution is to use a Multiple choice with comments type question and hide some of the text inputs with JavaScript or CSS.
Quick javascript solution :BBCMResearch wrote: Tony,
I'm having this same problem can you link to any javascript that's been posted about this? I haven't come across it yet.
Thanks!
<script> $(function() { $("#answer{SGQ}SQ0001comment").hide(); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#question'+{QID}+' .comment-container:eq(0) *').remove(); // First input $('#question'+{QID}+' .comment-container:eq(1) *').remove(); // Second input }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var qID = {QID}; // The sub-question codes to have no text input var sqCodes = [1, 2, 3, 4]; // Loop through those sq codes and remove their text inputs $(sqCodes).each(function(i, code) { $('#question'+qID+' input[type="text"][id$="X7441'+code+'comment"]').remove(); }); // The number of answers to be fixed at the end of the list var fixedAnswers = 2; // Find the number of answers var ansCount = $('#question'+qID+' .answer-item').length; // Place the last n answers created at the end of the list var fixedIndex = fixedAnswers - 1; for (var i=0; i<fixedAnswers; i++) { var answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]'); var answerItem = $(answer).closest('.answer-item'); var answersList = $(answer).closest('.answers-list'); if($('#question'+qID).hasClass('multiple-opt')) { answerItem = $(answer).closest('.answer-item').parent(); answersList = $(answer).closest('.subquestion-list'); } if($('#question'+qID).hasClass('multiple-opt-comments')) { answersList = $(answer).closest('tbody'); } $(answersList).append(answerItem); fixedIndex--; } }); </script>