Welcome to the LimeSurvey Community Forum

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

show array subquestions one at a time in array dual scale

  • Luca_W
  • Luca_W's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 1 month ago #238950 by Luca_W
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition
Version 3.28.29+220920
==================
Hi everyone! 

I want to put a couple of subquestions into an array dual scale question, but I want the subquestions to appear one at a time and dissapear when answered. I found a solution for an array single scale on  this thread  (the code provided by tpartner) and it looks exactly how I imagined it, but this code doesn't work for dual scale. I don't know enough about java script to adjust the code so it works on a dual scale question and haven't found a solution for this in the forum.

Any advice on how I need to adjust the code is greatly appreciated!

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 1 month ago #238984 by tpartner
Can you attach a small sample survey (.lss file) containing only the relevant question?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Luca_W
  • Luca_W's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 1 month ago #238996 by Luca_W
Hey tpartner, thanks for the quick reply!

I attached a sample survey, the first question group shows the array question in its current state, the two array questions are seperate and appear in randomized order one by one. The second question group shows the two array questions combined in an array dual scale question also using your code, but the subquestions dissappear after one of the two questions is answered, leaving no possibility to answer the second question, because it's triggered with the first click i guess. What I would like to have is this array dual scale question, but the subquestion dissapears after both scales are answered. 

Thanks a lot!

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 1 month ago #238997 by tpartner
Did you intentionally enable "no answer"?

 

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Luca_W
  • Luca_W's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 1 month ago #239000 by Luca_W
Ah, no I didn't, it just default activated, I created the sample survey I somewhat of a rush. I don't need the "no answer" field.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 1 month ago #239013 by tpartner
Okay, this script will check for two selected radios before moving on:

Code:
<script type="text/javascript" data-author="Tony Partner">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
    var thisTable = $('table.subquestion-list:eq(0)', thisQuestion);
 
    // Hide all but the first array rows
    $('tbody tr:not(:first)', thisQuestion).hide();
 
    // Remove repeat heading rows
    if($('tbody', thisTable).length > 0) {
      $('tbody:gt(0) tr[id^="javatbd"]', thisTable).appendTo($('tbody:eq(0)', thisTable));
      $('tbody:gt(0)', thisTable).remove();
    }
 
    // Listener on the radios for dual-scale array
    $('.answer-item :radio', thisQuestion).on('click', function(event) { 
      var thisRow = $(this).closest($('tr[id^="javatbd"]'));
      var nextRow = thisRow.nextAll('tr[id^="javatbd"]:eq(0)');
      if(nextRow.length > 0 &amp;&amp; $(':radio:checked', thisRow).length  > 1) {
         thisRow.fadeOut(300, function(e) {
           nextRow.fadeIn(300);
         });
      }
    });
    });
</script>

Sample survey:  

File Attachment:

File Name: limesurvey...5147.lss
File Size:57 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: Luca_W

Please Log in to join the conversation.

  • Luca_W
  • Luca_W's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 1 month ago #239048 by Luca_W
Perfect, thanks a ton!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose