- Posts: 7
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
//Add columns heads $("#question27 thead tr").append("<th></th>") $("#question27 thead tr").append("<th>Comment</th>") //Append other array row to each row of the main table l1 = $("#question27 tr") l2 = $("#question294 tr") for (var i = 1; i < l1.length ; i++){ l1[i].innerHTML += (l2[i].innerHTML) } //Hide the other array $("#question294").hide() //This is just for my needs, you really don't need it : Hide the row with empty labels var l1 = $("#question27 .answers-list .answertext") var l3 = $("#question27 .answers-list") for(var i=0; i < l1.length*2 - 1;i+=2){ if(l1[i].innerHTML.replace('\t','').indexOf("<input") < 2){ l3[i/2].innerHTML = "" } }
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).next('div[id^="question"]'); // Hide the multi-text question $(nextQuestion).hide(); // Add extra cells to the array rows $('.subquestions-list thead tr', thisQuestion).append('<th />'); $('.subquestions-list tbody tr', thisQuestion).append('<td />'); // Move the multi-text question text to the last column header cell of the array $('.subquestions-list thead tr th:last', thisQuestion).text($('.questiontext', nextQuestion).text()); // Move the text inputs $('input.text', nextQuestion).each(function(i){ $('.subquestions-list tbody tr:eq('+i+') td:last', thisQuestion).append(this); }); // Some cleanup styles (for the default template) $('col', thisQuestion).css({ 'width': 'auto' }); $('.subquestions-list tbody th, .subquestions-list tbody td', thisQuestion).css({ 'padding': '4px 10px' }); }); </script>
subquestions-list class only for 2.0, what is your LS version.tbudelli wrote: .subquestions-list
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).next('div[id^="question"]'); // Hide the multi-text question $(nextQuestion).hide(); // Add extra cells to the array rows $('table.question thead tr', thisQuestion).append('<th />'); $('table.question tbody tr', thisQuestion).append('<td />'); // Move the multi-text question text to the last column header cell of the array $('table.question thead tr th:last', thisQuestion).text($('.questiontext', nextQuestion).text()); // Move the text inputs $('input.text', nextQuestion).each(function(i){ $('table.question tbody tr:eq('+i+') td:last', thisQuestion).append(this); }); // Some cleanup styles (for the default template) $('col', thisQuestion).css({ 'width': 'auto' }); $('table.question tbody th, table.question tbody td', thisQuestion).css({ 'padding': '4px 10px' }); }); </script>