Welcome to the LimeSurvey Community Forum

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

array filter in sub answer

  • delarammahdaviii
  • delarammahdaviii's Avatar
  • Offline
  • Senior Member
  • Senior Member
More
8 years 1 month ago #131062 by delarammahdaviii
Replied by delarammahdaviii on topic array filter in sub answer
can i use Subquestion Relevance for this cell : Qcode_6_d= 0
or some things like this ?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #131075 by holch
Replied by holch on topic array filter in sub answer
As far as I know, subquestion relevance will show/hide the whole subquestion depending on the relevance equation written in the field.

So the relevance equation 'Qcode_6_d" would mean that the subquestion (the whole line) should not be shown when that specific field is zero. Which doesn't make sense.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • delarammahdaviii
  • delarammahdaviii's Avatar
  • Offline
  • Senior Member
  • Senior Member
More
8 years 1 month ago #131103 by delarammahdaviii
Replied by delarammahdaviii on topic array filter in sub answer
so, what can i do ?
i thing most use JS code .
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago - 8 years 1 month ago #131126 by tpartner
Replied by tpartner on topic array filter in sub answer
Add this script to the question source. It will remove the last checkbox in the last row of the array.

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {  
 
    $('#question{QID} tr.subquestions-list:last td.question-item:last *').remove();
    });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...-2-3.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 1 month ago by tpartner.
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
More
7 years 3 months ago - 7 years 3 months ago #145557 by papnikol
Replied by papnikol on topic array filter in sub answer

tpartner wrote: Set up your survey to use JavaScript and add something like this to the question source:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    //Hide the last radio in the first row
    $('#question'+{QID}+' tr.answers-list:first input.radio:last').remove();
  });
</script>


Hi, I just started with limesurvey (using version Version 2.55.3).
I tried this solution and it works up to a point. The radio button becomes non-clickable but it still shows. I also tried hide() instead of remove() but it did not work. Any advice?
Last edit: 7 years 3 months ago by papnikol.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145591 by tpartner
Replied by tpartner on topic array filter in sub answer
Version 2.5x has pseudo-elements inserted for the radios. To remove those, use a script like this.

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
 
    //Hide the last radio in the first row
    $('#question'+{QID}+' tr.answers-list:first .answer-item:last *').remove();
 
  });
</script>

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 3 months ago #161474 by Els_Severens
Replied by Els_Severens on topic array filter in sub answer
Hello

I also want to hide the last radio button in an array, but only when a certain anwer is given to a previous question in an other group.

I tried this, but this did not work:


<script type="text/javascript" charset="utf-8">
//if (insitution.NAOK == "AP")
{ $(document).ready(function(){
//Hide the last radio in the first row

$('#question'+{QID}+' tr.answers-list:first input.radio:last').remove();
});}


I am using LS Version 2.67.1

thanks!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago - 6 years 3 months ago #161487 by tpartner
Replied by tpartner on topic array filter in sub answer
Without seeing the survey, I would think it should look something like this:

Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function() {
 
    if ('{insitution.NAOK}' == "AP") { 
      //Hide the last radio in the first row
      $('#question'+{QID}+' tr.answers-list:first input.radio:last').remove();
    }
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 3 months ago by tpartner.
The topic has been locked.
More
6 years 3 months ago #161592 by Els_Severens
Replied by Els_Severens on topic array filter in sub answer
Hi Tony

Thanks a lot for your answer, however I don't get it to work.
I attach my survey.

I get it to work when I only look at the question, however when the whole group is shown the radio-item is visible.

What I want is that depending on the answer in the first session. The radio-items in the second item wil dissapear. But at the moment I am not able to make for example the second radio-item of the second session dissapear anyway.

I hope my question is clear.

thanks a lot for your help!
Els
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #161605 by tpartner
Replied by tpartner on topic array filter in sub answer
Did you check for JavaScript errors from some other script?

Sorry, I don't understand "radio-items in the second item". All I see are arrays with a single sub-question. Can you attach a sample survey containing only the relevant questions?

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 3 months ago #161606 by Els_Severens
Replied by Els_Severens on topic array filter in sub answer
What I want is something like the first picture. Where you cannot choose one option. However when the previous question is also shown, you can choose all the options (see picture 2).

I added the survey with only these two questions.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #161608 by tpartner
Replied by tpartner on topic array filter in sub answer
This workaround was never intended to work with both questions on a single page. The filtering question needs to be on a previous page.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose