- Posts: 29
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify the questions var q1ID = '{QID}'; var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).next('div[id^="question"]'); var q2ID = $(nextQuestion).attr('id').replace(/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){ var thisCode = $(this).attr('id').split('X'+q2ID)[1]; $('.subquestions-list tbody tr[id$="X'+q1ID+thisCode+'"] td:last', thisQuestion).append(this); }); // Some cleanup styles $('col', thisQuestion).css({ 'width': 'auto' }); $('.subquestions-list tbody th, .subquestions-list tbody td', thisQuestion).css({ 'padding': '4px 10px' }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify the questions var q1ID = '{QID}'; var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).next('div[id^="question"]'); var q2ID = $(nextQuestion).attr('id').replace(/question/, ''); // A class for the array question $(thisQuestion).addClass('with-inserted-texts'); // Hide the multi-text question $(nextQuestion).hide(); // Add extra cells to the array rows $('.subquestion-list thead tr', thisQuestion).append('<th class="text-center" />'); $('.subquestion-list tbody tr', thisQuestion).append('<td />'); // Move the multi-text question text to the last column header cell of the array $('.subquestion-list thead tr th:last', thisQuestion).text($('.questiontext', nextQuestion).text()); // Move the text inputs $('input[type="text"]', nextQuestion).each(function(i){ var thisCode = $(this).attr('id').split('X'+q2ID)[1]; $('.subquestion-list tbody tr[id$="X'+q1ID+thisCode+'"] td:last', thisQuestion).append(this); }); // Insert some styles var newStyles = '.with-inserted-texts col { \ width: auto !important; \ } \ .with-inserted-texts .subquestion-list tbody th,\ .with-inserted-texts .subquestion-list tbody td { \ padding: 4px 10px; \ } \ .with-inserted-texts .subquestion-list tbody th,\ .with-inserted-texts .subquestion-list tbody td { \ height: 50px; \ vertical-align: middle; \ } \ .with-inserted-texts .radio label::before,\ .with-inserted-texts .radio label::after { \ }'; $('head').append('<style type="text/css">'+newStyles+'</style>'); }); </script>
Uncaught TypeError: Cannot read property 'replace' of undefined