- Posts: 30
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<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); }); }); // Insert selects $('.answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">...</option>\ <option value="1">Option 1</option>\ <option value="2">Option 2</option>\ <option value="3">Option 3</option>\ </select>'); // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change'); } else { $(this).closest('.answer-item').find('input:text').val('').trigger('change'); } }); // Returning to page $('.with-select input:text', thisQuestion).each(function(i) { var thisCell = $(this).closest('.answer-item'); var inputText = $.trim($(this).val()); $('select.inserted-select', thisCell).val(inputText); }); // Clean-up styles $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </script>
So you shouls show us your tries by sending a lss export of your survey.I transfer excel table to HTML, but the table HTML didn't work in limesurvey survey
<table style="border:0;padding:0;border-collapse:collapse;color:#000;width:100%"> <thead> <tr> <td class="td1">Which of the following are the BEST OPTIONS for you? </td> <td class="tdf"> </td> <td class="tdn"><strong>Scenario 1</strong></td> <td class="tdf"> </td> <td class="tdn"><strong>Scenario 2</strong></td> <td class="tdf"> </td> <td class="tdn"><strong>Scenario 3</strong></td> </tr> </thead> <tbody> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">Location</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">House type</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">Subquestion 3</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">Subquestion 4</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">Subquestion 5</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1">Subquestion 6</td> <td class="tdf"> </td> <td class="tdn">Option 1</td> <td class="tdf"> </td> <td class="tdn">Option 2</td> <td class="tdf"> </td> <td class="tdn">Option 3</td> </tr> <tr style="height: 6px; text-align: center;"> </tr> <tr> <td class="td1"><strong>Which house would you prefer to live?</strong></td> <td class="tdf"> </td> <td class="tdn"> </td> <td class="tdf"> </td> <td class="tdn"> </td> <td class="tdf"> </td> <td class="tdn"> </td> </tr> <tr> <td class="td1"><strong>Which house do you think is most suitable for old people?</strong></td> <td class="tdf"> </td> <td class="tdn"> </td> <td class="tdf"> </td> <td class="tdn"> </td> <td class="tdf"> </td> <td class="tdn"> </td> </tr> </tbody> </table>
<style type="text/css">thead td.tdn { background-color:#D4D7E4; text-align:center; font-size:11pt; padding-top:1em; padding-bottom:1em; vertical-align:middle; } thead td.td1 { background-color:#D4D7E4; text-align:left; padding-top:1em; padding-bottom:1em; vertical-align:middle; width:46%; } tbody td.td1 { background-color:#f2f2f2; text-align:left; font-size:11pt; vertical-align:middle; } tbody td.tdn { background-color:#f2f2f2; text-align:center; font-size:11pt; vertical-align:middle; } .tdf { text-align: center; width:=0%; } </style>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Move the radios $('.question-text table:eq(0) tr:nth-last-child(2) td:eq(2)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(0) *', thisQuestion)); $('.question-text table:eq(0) tr:nth-last-child(2) td:eq(4)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(1) *', thisQuestion)); $('.question-text table:eq(0) tr:nth-last-child(2) td:eq(6)', thisQuestion).append($('.subquestion-list .answers-list:eq(0) .answer-item:eq(2) *', thisQuestion)); $('.question-text table:eq(0) tr:last td:eq(2)', thisQuestion).append($('.subquestion-list .answers-list:eq(1) .answer-item:eq(0) *', thisQuestion)); $('.question-text table:eq(0) tr:last td:eq(4)', thisQuestion).append($('.subquestion-list .answers-list:eq(1) .answer-item:eq(1) *', thisQuestion)); $('.question-text table:eq(0) tr:last td:eq(6)', thisQuestion).append($('.subquestion-list .answers-list:eq(1) .answer-item:eq(2) *', thisQuestion)); // Some classes for presentation $('.question-text table:eq(0) input:radio', thisQuestion).closest('td').addClass('answer-item radio-item text-center radio'); $('.question-text table:eq(0) .radio-item label', thisQuestion).show(); // Click event on the table cells $('.question-text table:eq(0) .radio-item', thisQuestion).on('click', function(e) { $('input:radio', this).trigger('click'); }); $('.question-text table:eq(0) input:radio', thisQuestion).on('click', function(e) { e.stopPropagation(); }); // Clean-up styles $('.answer-container', thisQuestion).hide(); $('.question-text table:eq(0) .label-text', thisQuestion).remove(); $('.question-text table:eq(0) .radio-text', thisQuestion).css({ 'cursor': 'pointer' }); }); </script>
In the survey you sent there are neither subquestions nor answer options in the question.However when I use javascript to design my survey in school limesurvey system, it didn't work.
You'd better use a quota to screen out these peopleIn part0, Q00 is designed to go on or stop the survey, if choose "yes", the survey will go on; if choose "no", then jump to "end part" and end the survey.