Welcome to the LimeSurvey Community Forum

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

Modifying the Layout of a List with Comment Question

  • msalum1
  • msalum1's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 3 months ago - 2 years 3 months ago #232688 by msalum1
(Write here your question/remark) Please help us help you and fill where relevant: 
Your LimeSurvey version: LimeSurvey Community Edition   Version 5.4.3+220926
Own server or LimeSurvey hosting: LimeSurvey by an organization 
Survey theme/template: Array (Likert Scale with comment box)  
==================
Hello, 
Is there a way to move two of my options, i.e. "Prefer not to Answer" and "I don't have the Expertise" to another column? Please see attached. I would appreciate your response/suggestions. 

Last edit: 2 years 3 months ago by msalum1.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #232698 by tpartner
Place this script in the question source.

On larger screens it will:

1) Move the textarea below the radio inputs.
2) Add a second column for a defined number of radio inputs.

On smaller screens, there is still only a single column of radios.

Code:
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Number of items to move into the second column
    var moveNumber = 2;
 
    // Identify this question
    var thisQuestion = $('#question6646');
 
    // Move the textarea below the radios
    $('.answer-item.text-item', thisQuestion).removeClass('col-sm-6');
 
    // Insert a new column
    $('.answers-list.radio-list:eq(0)', thisQuestion).after('<div class="answers-list radio-list col-sm-6 col-xs-12">\
          <ul class="list-unstyled" role="radiogroup"></ul>\
      </div>');
 
    // Move the items
    var itemsLength = $('.radio-item', thisQuestion).length;
    console.log(itemsLength-moveNumber);
    $('.radio-item:gt('+(itemsLength-moveNumber-1)+')', thisQuestion).appendTo($('.answers-list.radio-list:eq(1) ul:eq(0)', thisQuestion));
    });
</script>



Sample survey attached: 

File Attachment:

File Name: limesurvey...4444.lss
File Size:42 KB

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

Please Log in to join the conversation.

  • msalum1
  • msalum1's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 3 months ago #232741 by msalum1
Thanks, Tony. Yeah, I can see that on a smaller screen it's on a single column.
If this is the case, is there a way to move the last two options of the radio list just below the comment box?

What I'm trying to achieve is to separate "Prefer not to answer" and "I don't have the expertise" from the Scale of Agreement. I would appreciate any suggestion if such is ever not possible.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #232824 by tpartner
Try this (untested):
Code:
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Number of items to move into the second column
    var moveNumber = 2;
 
    // Identify this question
    var thisQuestion = $('#question6646');
 
    // Move the textarea below the radios
    $('.answer-item.text-item, answers-list radio-list', thisQuestion).removeClass('col-sm-6');
 
    // Insert a new column
    $('.answer-item.text-item', thisQuestion).after('<div class="answers-list radio-list col-xs-12">\
          <ul class="list-unstyled" role="radiogroup"></ul>\
      </div>');
 
    // Move the items
    var itemsLength = $('.radio-item', thisQuestion).length;
    $('.radio-item:gt('+(itemsLength-moveNumber-1)+')', thisQuestion).appendTo($('.answers-list.radio-list:eq(1) ul:eq(0)', thisQuestion));
    });
</script>

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

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose