- Posts: 27
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<span class="qnumber">Q1</span> Please tell us the age and gender of everyone who lives with you in your household. <script type="text/javascript" charset="utf-8"> $(document).ready(function() { var newHeader = 'Age'; // Identify the questions var q1ID = '{QID}'; var q1 = $('#question'+q1ID+''); var q2 = $(q1).nextAll('.multiple-short-txt:eq(0)'); var q2ID = $(q2).attr('id').split('question')[1]; // Hide the second question $(q2).hide(); // Clean up the array widths imposed by LS $('.subquestions-list col', q1).css({ 'width':'auto' }); // Insert a new header in the array $('.subquestions-list thead td', q1).after('<th>'+newHeader+'</th>'); // Move the age inputs into the array $('.answers-list', q1).each(function(i) { $('.answertext', this).after('<td class="answer_cell_000"></td>'); }); $('input[type="text"]', q2).each(function(i) { $('.answer_cell_000:eq('+i+')', q1).append($(this)); }); // Some styles for the array (this could be done in template.css) $('.subquestions-list th, .subquestions-list td', q1).css({ 'padding':'3px 7px' }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var newHeader = 'Age'; // Identify the questions var q1ID = '{QID}'; var q1 = $('#question'+q1ID+''); var q2 = $(q1).nextAll('.multiple-short-txt:eq(0)'); var q2ID = $(q2).attr('id').split('question')[1]; // Hide the second question $(q2).hide(); // Clean up the array widths imposed by LS $('.subquestions-list col', q1).css({ 'width':'auto' }); // Insert a new header in the array $('.subquestions-list thead th:last', q1).after('<th>'+newHeader+'</th>'); // Move the age inputs into the array $('.answers-list', q1).each(function(i) { $('td.answer-item:last', this).after('<td class="answer_cell_000"></td>'); }); $('input[type="text"]', q2).each(function(i) { $('.answer_cell_000:eq('+i+')', q1).append($(this)); }); // Some styles for the array (this could be done in template.css) $('.subquestions-list th, .subquestions-list td', q1).css({ 'padding':'3px 7px' }); }); </script>
tpartner wrote: Untested, but it seems to me that this should do the trick:
Mazi wrote: Please post a link to an activated test survey so we can have a look at the live version.
Mazi wrote: Please post a link to an activated test survey so we can have a look at the live version.
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var newHeader = 'Age'; // Identify the questions var q1ID = '{QID}'; var q1 = $('#question'+q1ID+''); var q2 = $(q1).nextAll('.multiple-short-txt:eq(0)'); var q2ID = $(q2).attr('id').split('question')[1]; // Hide the second question $(q2).hide(); // Clean up the array widths imposed by LS $('.subquestions-list col', q1).css({ 'width':'auto' }); // Insert a new header in the array $('.subquestions-list thead th:last', q1).after('<th>'+newHeader+'</th>'); // Move the age inputs into the array $('.answers-list', q1).each(function(i) { $('td.answer-item:last', this).after('<td class="answer_cell_000 answer-item radio-item"><label>'+newHeader+'</label></td>'); }); $('input[type="text"]', q2).each(function(i) { $('.answer_cell_000:eq('+i+')', q1).append($(this)); }); // Some styles for the array (this could be done in template.css) $('.subquestions-list th, .subquestions-list td', q1).css({ 'padding':'3px 7px' }); }); </script>
.subquestions-list .answer_cell_000 label::before, .subquestions-list .answer_cell_000 .label::before { content: ""; } .subquestions-list .answer_cell_000 label { display:none; } @media (max-width: 768px) { .subquestions-list .answer_cell_000 { padding: 3px 7px 3px 15px !important; text-align: left; } .subquestions-list .answer_cell_000 label { display:inline-block; width: 50%; color: #4d4d4d; text-align: left; } .subquestions-list .answer_cell_000 input { display:inline-block width: 50%; } }
Mazi wrote: Thanks for the support, Tony!
tpartner wrote: No thanks until we know it works