- Posts: 18
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $( "<tbody ><tr class='array1'><th class='answertext' >New Label</th><td colspan='5'></tr>" ).insertBefore( "#javatbdxxxxxx" ); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $( "<tbody ><tr class='array1'><th class='answertext' >New Label</th><td>connaissance</td><td>contacts</td><td>partenariats</td><td>sans réponse</td></tr>" ).insertBefore( "#javatbdxxxxxx" ); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Create a new "sub-header" row var subHeader = $('table.subquestions-list thead tr:eq(0)', thisQuestion).clone(); $('td:eq(0)', subHeader).remove(); subHeader.addClass('sub-header'); subHeader.prepend('<th class="answertext">New Label</th>'); // Insert the new "sub-header" row $('#javatbdxxxxxx').after(subHeader); }); </script>
dla wrote: ... {QID}'" : what does it bring to enter QID here since it doesnt appear necessary?
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); //Insert the first header label $('table.subquestions-list thead tr:eq(0)', thisQuestion).addClass('sub-header-row'); $('table.subquestions-list thead tr:eq(0) td:eq(0)', thisQuestion).remove(); $('table.subquestions-list thead tr:eq(0)', thisQuestion).prepend('<th class="sub-header-text">Sub-Header 1</th>'); // Create a clone of the top header row var subHeader = $('table.subquestions-list thead tr:eq(0)', thisQuestion).clone(); // Insert a clone of the clone after row 2 $('.sub-header-text', subHeader).text('Sub-Header 2'); $('tr.answers-list:eq(1)', thisQuestion).after(subHeader.clone()); // Insert a clone of the clone after row 5 $('.sub-header-text', subHeader).text('Sub-Header 3'); $('tr.answers-list:eq(4)', thisQuestion).after(subHeader.clone()); // Fix up the row classes var rowClass = 1; $('table.subquestions-list tbody tr', thisQuestion).each(function(i) { if($(this).hasClass('sub-header-row')) { rowClass = 1 } else { rowClass++; $(this).removeClass('array1 array2') if(rowClass % 2 == 0) { $(this).addClass('array2'); } else { $(this).addClass('array1'); } } }); }); </script>
.sub-header-row { background-color: #999999; } .sub-header-row th { font-weight: bold; text-align: center; color: #FFFFFF; background-color: transparent !important; }