Welcome to the LimeSurvey Community Forum

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

Incorrect display in second page filtered array

  • UdeSherbrooke
  • UdeSherbrooke's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago - 7 years 7 months ago #141487 by UdeSherbrooke
Hello, would someone be able to help me with this issue ? Thanks for you help

For my survey
Page 1: a list of substances used in lifetime (tobacco, alcohol, etc.)
Page 2: only the substances used in lifetime should appeared and another question is asked

I found this Java Script below to insert in page 2 source. The problem is that only the items with no answer on page 1 appear appear on page 2.

FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:
• <script type="text/javascript" charset="utf-8">
• $(document).ready(function() {
• filterArrByCol(MM, AA, 2);
• });
• </script>
Last edit: 7 years 7 months ago by UdeSherbrooke.
The topic has been locked.
More
7 years 7 months ago #141493 by jelo
I am not sure why you need such a javascript. Where did you find it? And what LimeSurvey version/build do you use?

You can use array filter to only show selected items in later questions.
manual.limesurvey.org/Question_type_-_Mu...r_.28array_filter.29

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • UdeSherbrooke
  • UdeSherbrooke's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 7 months ago #141561 by UdeSherbrooke
Replied by UdeSherbrooke on topic Incorrect display in second page filtered array
Hello,

Thank you for you reply, I very much appreciate it ! I use the following version of Lime Survey : Version 2.00+ Build 130325. I already know the link you sent me but for me it does not work (or I don't do it properly).

I found this Java Script Code on this website : manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript

The instructions with are the following
FOR FILTER AND ARRAY QUESTIONS ON SEPARATE PAGES:
Create a multiple options question on page 1.
Create a multiple options question and an array-by-column question on page 2.
All three questions MUST have identical sub-questions and sub-question codes.
Set the multiple options on page 2 to be filtered by the multiple options on page 1.
Place the following script in the source of one of the questions on page 2.
Replace "MM" with the ID of the multiple options question and "AA" with the ID of the array question. Do not modify the "1".
The function will hide the multiple options question. If options were selected in the multiple options on page 1, the corresponding options will be checked in the hidden multiple options question which will then be used to control the display of the array columns.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
filterArrByCol(MM, AA, 2);
});
</script>
The topic has been locked.
More
7 years 7 months ago #141563 by jelo

UdeSherbrooke wrote: I already know the link you sent me but for me it does not work (or I don't do it properly).

Even though your LimeSurvey version is too old, the array filter feature is available in the advanced options of the question.
So you just need to edit the second question and add the question code of the first question into the array filter field.
You have to keep answer codes of first and second question identical.

The manual states:

To set a filter
Enter the question code of a multiple options question to use as the source information into the setting for array filter. For example, if your source multiple option question code is "Q1" enter "Q1" into either the 'Array Filter' input or the 'Array Filter Exclusion' input in the advanced settings of the question you want to filter. Only answer options that are selected in question Q1 will be visible in the array_filter-ed question.
Array filter question settings require the questions being used to have exactly matching lists of answers. If the questions do not have exactly the same set of answers and codes, then the filters will break.


The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: tpartner
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose