- Posts: 73
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
Question <script type="text/javascript" charset="utf-8"> $(document).ready(function() { // The number of answers to be fixed at the end of the list var fixedAnswers = 1; // Identify this question var qID = {QID}; // 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'); } $(answersList).append(answerItem); fixedIndex--; } }); </script><script> $(function() { $("#answer{SGQ}1comment").hide(); }); </script><script> $(function() { $("#answer{SGQ}2comment").hide(); }); </script><script> $(function() { $("#answer{SGQ}3comment").hide(); }); </script><script> $(function() { $("#answer{SGQ}4comment").hide(); }); </script>
Hi,holch wrote: But to be honest, I think the option to have more than one comment field / other field should be part of the main package, for multiple choice and single choice questions. It is a pretty standard requirement in research and not something that should require the installation of a specific plugin.
Try this updated script which should also handle multiple choice with comments.I currently have an 'Other' option that needs to be pegged at the bottom, however, I can't seem to get the 'multiple choice' workaround to work for 'multiple choice with comments.'
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // The number of answers to be fixed at the end of the list var fixedAnswers = 1; // Identify this question var qID = {QID}; // 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>
Why not use single choice with comments?Also, all of these subquestions have to be exclusive options.