Welcome to the LimeSurvey Community Forum

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

Dual Scale Array, getting rid of one side for one question

  • rickyd
  • rickyd's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 7 months ago #121992 by rickyd
Hello,

I'm trying to create a dual scale array question with many similar subquestions. For one subquestion, however, I'd like to get rid of the first scale's radio buttons and only have radio buttons in the second. I could just create another question, however for the sake of the look of the survey I'd rather have everything all together in one question. Is this something that is possible? Thank you.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago - 8 years 7 months ago #122018 by tpartner
Set up your survey to use JavaScript and add something like this to the source of the question (modify rowNumber as required):

Code:
<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>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 7 months ago by tpartner.
The topic has been locked.
More
6 years 4 months ago #158943 by DerBibber17
Hey!
I have a similar question. I want some of the subquestions in my arrays (numbers with checkboxes) or multiple choice questions only to be category separators (like it is possible to choose for list dropdown). As far as I can see limesurvey is not offering category separators in arrays or multiple choice questions.

So my idea would be to hide the checkboxes (of an array) or the radio buttons (of a multiple choice) in the rows that should only be headers for the following subquestions.
My JavaScript skills are kind of limited, so I would be grateful for some help.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #159001 by Joffm

I want some of the subquestions in my arrays (numbers with checkboxes) or multiple choice questions only to be category separators


For multiple choice maybe this helps (Tony's script).
www.limesurvey.org/forum/can-i-do-this-w...e-in-multiple-choice

Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DerBibber17
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago - 6 years 4 months ago #159010 by tpartner
Regarding arrays, rather than hiding check-boxes, I would insert new sub-header rows. Something like this - www.limesurvey.org/forum/design-issues/1...-one-question#155220

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 4 months ago by tpartner.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #159011 by tpartner
...here is that JavaScript, modified slightly for array-numbers-checkboxes:

Code:
<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>

And, the CSS:
Code:
.sub-header-row {
  margin-bottom: 20px;
}
 
 
.sub-header-row th {
  background-color: #547599;
  color: #FFFFFF !important;
  text-align: center;
}


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 4 months ago #159053 by DerBibber17
Thank you for the script :) Unfortunately it's not working. I inserted the script into the source of the question but nothing happens. I also tried some other things (like adding an "other"-option with textfield to some of my question), but nothing is working.
So i was wondering, if the problem is that I'm using limesurvey via my University which is offering only the german limesurvey version while the scripts are in english. Could this be part of the problem?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #159055 by tpartner
The script language does not matter.

See here for instructions on how to insert scripts - manual.limesurvey.org/Workarounds:_Manip...tc..29_in_LimeSurvey

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 4 months ago #159107 by DerBibber17
Ok so I don't know why it's not working.
Do I have to change something in the script when I'm using it in my question (except the Subheadings)?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #159110 by tpartner
Can you activate a test survey and give a link here?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 4 months ago #159155 by DerBibber17
In the meanwhile I got a new problem. I couldn't activate my survey because I've got to many subquestions in it. So here's a link to just one question group of my survey.
In this group are for example 3 questions in which I would like to use sub-headers. One question with multiple numerical input and two arrays (I already changed the multiflex arrays so I dont need sub-headers in them anymore). The bold subquestion you see now should be only subheaders.
Thank you so much!

survey.tugraz.at/index.php/survey/index/...65/newtest/Y/lang/de
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago - 6 years 4 months ago #159156 by Joffm
Hello, Bibber,

Do I have to change something in the script when I'm using it in my question (except the Subheadings)?

You have to change this:
Code:
// Define the sub-heading text strings
    var subHeading1 = 'Subheading 1';
    var subHeading2 = 'Subheading 2';
    var subHeading3 = 'My third subheading';
and this (where does the subheading appear):
Code:
// 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>');

I got this result:



And this for your "normal" matrix (without any css to style the header row)


sample file attached

In the meanwhile I got a new problem. I couldn't activate my survey because I've got to many subquestions in it.

Well, that's something different. So either you try to shorten your survey or you have to split it.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 4 months ago by Joffm.
The following user(s) said Thank You: tpartner, DerBibber17
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose