- Posts: 8
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Answer based on previous question
- pimp_m
- Topic Author
- Offline
- New Member
Less
More
8 years 11 months ago #119644
by pimp_m
Answer based on previous question was created by pimp_m
Hi Friends,
Can anyone advise on multiple choice question condition.
Example question;
Q1. Please choose two:
[] Apple
[] Banana
[] Mango
[] Orange
[] Coconut
[] Grape
Answer for this question will not appear on next question.
Let say participant choose Banana & Mango for Q1, the answer for Q2 as follow:
Q2. Please choose two:
[] Apple
[] Orange
[] Coconut
[] Grape
If participant tick Orange & Coconut for Q1, the answer for Q2 as follow:
Q2. Please choose two:
[] Apple
[] Banana
[] Mango
[] Grape
thanks
Can anyone advise on multiple choice question condition.
Example question;
Q1. Please choose two:
[] Apple
[] Banana
[] Mango
[] Orange
[] Coconut
[] Grape
Answer for this question will not appear on next question.
Let say participant choose Banana & Mango for Q1, the answer for Q2 as follow:
Q2. Please choose two:
[] Apple
[] Orange
[] Coconut
[] Grape
If participant tick Orange & Coconut for Q1, the answer for Q2 as follow:
Q2. Please choose two:
[] Apple
[] Banana
[] Mango
[] Grape
thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 11 months ago #119655
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Answer based on previous question
Please refer to the manual - Array Filter -
manual.limesurvey.org/Question_type_-_Mu...r_.28array_filter.29
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- pimp_m
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
8 years 11 months ago #119664
by pimp_m
Replied by pimp_m on topic Answer based on previous question
tq
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 11 months ago #119671
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Answer based on previous question
Hi Tony,
I'm always quiet lost when I want to exclude (disable or hide) more than 1 answer option in the 2nd multiple-choice question:
Q1: Fruit or vegetable
[fruit] fruit
[veget] vegetable
Q2: Detailed list
[frui1] apple
[frui2] orange
[vege1] celery
[vege2] spinach
May you help me to write the correct jQuery syntax on a stone...
I'm always quiet lost when I want to exclude (disable or hide) more than 1 answer option in the 2nd multiple-choice question:
Q1: Fruit or vegetable
[fruit] fruit
[veget] vegetable
Q2: Detailed list
[frui1] apple
[frui2] orange
[vege1] celery
[vege2] spinach
May you help me to write the correct jQuery syntax on a stone...
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 11 months ago - 8 years 11 months ago #119674
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Answer based on previous question
Hi Ben.
I would be inclined to insert a hidden copy of Q2 (call it qHidden) after Q1 and then use JavaScript to toggle the check-boxes in the hidden question. Corresponding food "group" sub-questions can be identified by the first 4 characters of sub-question codes.
Then you could filter Q2 by qHidden, allowing you to place it anywhere in the survey and make it mandatory (if necessary).
After adding that copy, place the following script placed in the source of Q1. I think the comments explain it but please ask if you are confused about any of it.
I would be inclined to insert a hidden copy of Q2 (call it qHidden) after Q1 and then use JavaScript to toggle the check-boxes in the hidden question. Corresponding food "group" sub-questions can be identified by the first 4 characters of sub-question codes.
Then you could filter Q2 by qHidden, allowing you to place it anywhere in the survey and make it mandatory (if necessary).
After adding that copy, place the following script placed in the source of Q1. I think the comments explain it but please ask if you are confused about any of it.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions and IDs var q1ID = {QID}; var q1 = $('#question'+q1ID); var qHidden = q1.nextAll('.multiple-opt:eq(0)'); var qHiddenID = qHidden.attr('id').replace(/question/, ''); // Hide qHidden qHidden.hide(); // Listeners on the Q1 checkboxes $('input.checkbox', q1).change(function(e) { var q1Checkbox = $(this); // Define the food "group" var foodGroup = $(this).attr('id').split('X'+q1ID)[1].substr(0, 4); // Loop through subquestions within the food "group" in qHidden $('input.checkbox[id*="X'+qHiddenID+foodGroup+'"]', qHidden).each(function(i) { // Toggle the checkbox(es) in qHidden $(this).prop('checked', $(q1Checkbox).prop('checked')); $(this).nextAll('input[type="hidden"]:eq(0)').attr('value', $(q1Checkbox).nextAll('input[type="hidden"]:eq(0)').attr('value')); // Fire the Expression Manager checkconditions() function checkconditions(this.value, this.name, this.type); }); }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 8 years 11 months ago by tpartner.
The following user(s) said Thank You: Ben_V
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 11 months ago - 8 years 11 months ago #119696
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Answer based on previous question
Thank you Tony...It's really a great help !
This code is working fine and I'm sure it will help other users too
The other good news is that it's very easy to disable (not hide) the Q2 answers options, just setting properly Q2 array filter exclusion and setting the question relevance to 1.
Thanks again
This code is working fine and I'm sure it will help other users too
The other good news is that it's very easy to disable (not hide) the Q2 answers options, just setting properly Q2 array filter exclusion and setting the question relevance to 1.
Thanks again
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Attachments:
Last edit: 8 years 11 months ago by Ben_V.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 11 months ago #119697
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Answer based on previous question
Ah, I didn't realize you wanted to exclude those answers, I thought you simply wanted to filter them. Another good reason to use the hidden question - it will work for both filter and exclusion-filter.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 11 months ago #119699
by Ben_V
...the ultimate swiss army knife for multiple-choice questions !
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Answer based on previous question
it will work for both filter and exclusion-filter
...the ultimate swiss army knife for multiple-choice questions !
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
8 years 11 months ago - 8 years 11 months ago #119707
by DenisChenu
I use same system for "filter by array" system.
And if question are not in same group : it's more easy.
See : demonstration.sondages.pro/676785 .
Tony and me have some different method (example : to find the baseSGQ : Tony use javascript, i use EM)
But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.
Denis
PS: survey in freanch, but i know Ben read french
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Answer based on previous question
Hi,tpartner wrote: I would be inclined to insert a hidden copy of Q2 (call it qHidden) after Q1 and then use JavaScript to toggle the check-boxes in the hidden question. Corresponding food "group" sub-questions can be identified by the first 4 characters of sub-question codes.
I use same system for "filter by array" system.
And if question are not in same group : it's more easy.
See : demonstration.sondages.pro/676785 .
Tony and me have some different method (example : to find the baseSGQ : Tony use javascript, i use EM)
But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.
Denis
PS: survey in freanch, but i know Ben read french
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Attachments:
Last edit: 8 years 11 months ago by DenisChenu.
The following user(s) said Thank You: Ben_V
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 11 months ago - 8 years 11 months ago #119716
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Answer based on previous question
Hi Denis, thank you for your tips & sample
Aspirin retail sales will probably plunge...But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 8 years 11 months ago by Ben_V.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
8 years 11 months ago #119718
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Answer based on previous question
Ben_V wrote:
Aspirin retail sales will probably plunge...But in 2.06 : we don't need any javascript \o/ : each subquestion have own relevance equation.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Attachments:
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 11 months ago #119723
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Answer based on previous question
"pour le plaisir des yeux..."
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.