Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Changing background colour of rows in array / Suppressing the grouping of rows

  • zschaerer
  • zschaerer's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155363 by zschaerer
I have created a customised array question with sliders and yes/no buttons by using this great workaround: www.limesurvey.org/forum/design-issues/1...s-no-question#155360

I extended it a bit because I wanted the labels of each slider to be randomly displayed on the left and right side of the slider (e.g. good - bad vs. bad - good). To achieve this, I created each question in two versions (one version labelled good - bad and one version labelled bad - good). A script then creates a random number 0 or 1 and depending on this number, one version of the question is hidden.

This now leads to the problem that the background colour of the rows is not alternating anymore because in some cases two rows with the same colour are displayed directly one after the other. How can I adjust that?

A second problem (has nothing to do with the workaround) is that if I have more than 5 questions, the rows are automatically grouped into groups of 5 and a quite large white frame is inserted between these groups. How can I switch that off?


See attached test survey.

File Attachment:

File Name: limesurvey...5-31.lss
File Size:30 KB
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago #155381 by tpartner
Regarding the background colours, see "Fix up the row background colours" in the script I just posted in your other thread - www.limesurvey.org/forum/design-issues/1...tion?start=15#155380

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Fix up the row background colours
    var rowIndex = 0;
    $('table.subquestion-list tbody tr', thisQuestion).each(function(i){
      rowIndex ++;
      $(this).removeClass('array1, array2');
      if(rowIndex % 2 == 0) {
        $(this).addClass('array1');
      }
      else {
        $(this).addClass('array2');
      }
    });
  });
</script>

Regarding the row grouping, I suspect it is the "Repeating headings in array questions every X subquestions".


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: zschaerer
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose