- Posts: 45
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
see a non-working printscreen below
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var qArrayID = {QID}; var qArray = $('#question'+qArrayID); // var arrayLength = $('tr.answers-list', qArray).length; var qMultiText = qArray.nextAll('.multiple-short-txt:eq(0)'); // Hide the multi-short-text question $(qMultiText).hide(); var tableWidth = $('table.questions-list:eq(0)', qArray).width(); var answerWidth = $('col.ls-col-odd:eq(0)', qArray).width(); var answerWidthPercent = (answerWidth/tableWidth)*100; var answersLength = $('col.ls-col-odd, col.ls-col-even', qArray).length; var answerWidthPercent2 = (answerWidthPercent*answersLength)/(answersLength+1) $('table.questions-list col', qArray).removeAttr('width'); $('table.questions-list col:not(.col-answers)', qArray).css('width', 'auto'); $('table.questions-list thead tr', qArray).append('<th class="answer-text inserted-column-label" /></th>'); $('table.questions-list thead tr th.answer-text.inserted-column-label', qArray).css('width','30%'); $('tr.answers-list', qArray).each(function(i) { $(this).append('<td class="answer-item text-item">\ </td>\ '); }); // Load the column label for the text inputs $('.inserted-column-label:eq(0)', qArray).text($('.ls-label-question', qMultiText).text()); $('.text-item', qArray).append('<label class="ls-label-xs-visibility">'+$('.ls-label-question', qMultiText).text()+'</label>'); // 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)); }); }); </script>
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify the questions var thisQID = {QID}; var thisQuestion = $('#question'+thisQID); var textQuestion = thisQuestion.nextAll('.multiple-short-txt:eq(0)'); var textQID = textQuestion.attr('id').replace(/question/, ''); // Hide the text question textQuestion.hide(); // Remove all radios from last column $('.answer-item:last-child', thisQuestion).removeClass('radio-item').addClass('text-item'); $('.answer-item:last-child :radio', thisQuestion).remove(); // Move the text inputs $('tr.answers-list', thisQuestion).each(function(i) { var thisCode = $(this).attr('id').split('X'+thisQID)[1]; $('.answer-item:last-child', this).append($(':text[id$="X'+textQID+thisCode+'"]', textQuestion)); }); }); </script>