- 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() { // 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; }
The JS does work in IE, I have tested in IE 7-11, what version are you using? Do you have JavaScript enabled?...but (given that you use javascript) id does not with Internet Explorer.
Again, I tested in Firefox, Chrome, Safari, IE 7-11 and the only problem I saw was in some early versions of IE7 which the following CSS rules should fix....with Firefox it works fine, but I can't see the different background color of the header.
.sub-header-row { background-color: #999999; } .sub-header-row th { font-weight: bold; text-align: center; color: #FFFFFF; background-color: transparent !important; *background-color: #999999 !important; } .checkedLabel { color:#009900; }
.sub-header-row { background-color: #999999; } .sub-header-row th { font-weight: bold; text-align: center; color: #FFFFFF; background-color:#999999 !important; } .checkedLabel { color:#009900; }