Welcome to the LimeSurvey Community Forum

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

Hiding row in an array type question

  • tarantel999
  • tarantel999's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 weeks ago #105838 by tarantel999
Hiding row in an array type question was created by tarantel999
Hi!

Problem:
- q1 array with 1-10p. scale
- In q2 show only rows where the respondent has picked 2p. or higher

I've used EM in subquestion, it works well clearing out the row title, but not hide-ing it. Is there an easy way to do it? Javascript?

{if((q1_A1.NAOK > "2"),Attribute 1,'')}
{if((q1_A2.NAOK > "2"),Attribute 2,'')}
{if((q1_A3.NAOK > "2"),Attribute 3,'')}
{if((q1_A4.NAOK > "2"),Attribute 4,'')}

Thanks in advance!
The topic has been locked.
More
10 years 1 week ago - 10 years 1 week ago #105967 by Bigred01
Replied by Bigred01 on topic Hiding row in an array type question
I just create a hidden multiple choice question with the same amount of subquestions. I will auto answer the corresponding multiple choice option if the array answer is >= 2 then use the build in array filter.

Below is the exact code of a working version I just made. In this example my array subquestions are numbered a1-a5.
Code:
$(document).ready(function() {
 
$('#movenextbtn, #movesubmitbtn').click(function () {
var subNum = 0;
 
//replace the 5 with the number of array rows you have.
for(var i = 0;i < 5;i++) {
 
subNum = i + 1;
 
console.log(subNum);
 
  //replace "java936471X86X336a" with your id that stores the array value. You will find it under ".answertext". 
  if(document.getElementById('java936471X86X336a'+subNum).value >= "2") {
 
    //replace the question number with your multiple choice questions number.
    $('#question342 .checkbox:eq('+i+')').attr('checked', true).triggerHandler('click');
  }
  }
});
});
 

In the next question use the SGQA code in the array filter option under advanced settings. Be sure to number them the same.
Last edit: 10 years 1 week ago by Bigred01.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose