- Posts: 8
- 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() { // The row to hide var rowNumber = 2; // Identify some elements var thisQuestion = $('#question{QID}'); var hiddenRow = $('tr.radio-list:eq('+(rowNumber-1)+')', thisQuestion); // Assign column-specific classes $('tr.radio-list', thisQuestion).each(function(i){ var column = 1; var scale = 1; $('td', this).each(function(i){ if($(this).hasClass('radio-item')) { $(this).addClass('scale-'+scale+' column-'+column+''); column++; } else { column = 1; scale = 2; } }); }); // Click the first radio in the hidden row (in case of mandatory) $('.column-1.scale-1 input.radio', hiddenRow).trigger('click'); // Hide the radios $('.scale-1 input.radio', hiddenRow).hide(); }); </script>
I want some of the subquestions in my arrays (numbers with checkboxes) or multiple choice questions only to be category separators
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Define the sub-heading text strings var subHeading1 = 'Subheading 1'; var subHeading2 = 'Subheading 2'; var columnsLength = $('tr.subquestion-list:eq(0) > *', thisQuestion).length; // Insert the new rows $('tr.subquestion-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>'); $('tr.subquestion-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>'); // Fix up the row classes var rowClass = 1; $('table.subquestion-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 { margin-bottom: 20px; } .sub-header-row th { background-color: #547599; color: #FFFFFF !important; text-align: center; }
You have to change this:Do I have to change something in the script when I'm using it in my question (except the Subheadings)?
// Define the sub-heading text strings var subHeading1 = 'Subheading 1'; var subHeading2 = 'Subheading 2'; var subHeading3 = 'My third subheading';
// Insert the new rows $('tr.subquestion-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>'); $('tr.subquestion-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>'); $('tr.subquestion-list:eq(5)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+My third subHeading+'</th></tr>');
Well, that's something different. So either you try to shorten your survey or you have to split it.In the meanwhile I got a new problem. I couldn't activate my survey because I've got to many subquestions in it.