- Posts: 40
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Disabled answer in a question base on selected answer in previous question
- jajas
- Topic Author
- Offline
- Senior Member
Less
More
9 years 3 months ago #115735
by jajas
Disabled answer in a question base on selected answer in previous question was created by jajas
Dear LS Team,
How to disabled answer in a question base on selected answer in previous question.
bellow is the figure:
C1. Do you know the Ferrari Team [Single Answer]
[1] Yes
[2] No
C2. Do you know the Ferrari Team to be champion [Single Answer]
[1] Yes
[2] No
C3. How deep you know about Ferrari[Single Answer]
[1] I don't know
[2] I don't know att all
[3] I know it very much
[4] I'm very Friendly with Ferrari
i need to disable the answer 3 & 4 in Question C3 if in question C1 and C2 selected "NO" answer.
Need your help to solve it
Regards,
Jajas
How to disabled answer in a question base on selected answer in previous question.
bellow is the figure:
C1. Do you know the Ferrari Team [Single Answer]
[1] Yes
[2] No
C2. Do you know the Ferrari Team to be champion [Single Answer]
[1] Yes
[2] No
C3. How deep you know about Ferrari[Single Answer]
[1] I don't know
[2] I don't know att all
[3] I know it very much
[4] I'm very Friendly with Ferrari
i need to disable the answer 3 & 4 in Question C3 if in question C1 and C2 selected "NO" answer.
Need your help to solve it
Regards,
Jajas
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
9 years 3 months ago - 9 years 3 months ago #115766
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 Disabled answer in a question base on selected answer in previous question
Currently there is no built-in filtering for answers. You can use JavaScript, a hidden multiple-choice question and array filtering to mimic it...or just use two separate questions.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 3 months ago by tpartner.
The topic has been locked.
- jajas
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
9 years 3 months ago #115769
by jajas
Replied by jajas on topic Disabled answer in a question base on selected answer in previous question
Can you give me a sample, Please?
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
9 years 3 months ago #115770
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 Disabled answer in a question base on selected answer in previous question
Searching the forum should yield some examples. Here is one for arrays that could be easily adapted for your needs -
www.limesurvey.org/en/forum/can-i-do-thi...estion-result#112088
.
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jajas
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
9 years 3 months ago #115790
by jajas
Replied by jajas on topic Disabled answer in a question base on selected answer in previous question
I think it's different case. hmmm...
The topic has been locked.
- Bigred01
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 33
9 years 2 months ago #115832
by Bigred01
Replied by Bigred01 on topic Disabled answer in a question base on selected answer in previous question
Assuming your questions are on different pages and C3 is the only radio question on its page you could do something like...
Code:
$(document).ready(function() { var prevAns = "{C1.NAOK} " === "2" && "{C2.NAOK} " === "2" ; if(prevAns) { $(".radio:eq(2),.radio:eq(3)").attr("disabled",true); } });
The topic has been locked.
- jajas
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
9 years 2 months ago #115833
by jajas
Replied by jajas on topic Disabled answer in a question base on selected answer in previous question
Hi Bigred,
Thanks for replay. in my case the question in same page.
could u give me a script sample for case in same page.
Thanks for replay. in my case the question in same page.
could u give me a script sample for case in same page.
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
9 years 2 months ago #115835
by tpartner
The following script is placed in the source of a hidden multiple-choice question that is inserted between C2 and C3. The script toggles the check-boxes in the hidden question depending on the state of C2 and C3. Array filter exclusion then handles the display of the last two answers in C3.
Here's a sample survey:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Disabled answer in a question base on selected answer in previous question
Here is an example for your situation.I think it's different case. hmmm...
The following script is placed in the source of a hidden multiple-choice question that is inserted between C2 and C3. The script toggles the check-boxes in the hidden question depending on the state of C2 and C3. Array filter exclusion then handles the display of the last two answers in C3.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the elements var qHidden = $('#question{QID}'); var qC1 = qHidden.prevAll('.list-radio:eq(1)'); var qC2 = qHidden.prevAll('.list-radio:eq(0)'); var inputs = $('input[type="radio"]', qC1).add('input[type="radio"]', qC2); // Hide the filter question qHidden.hide(); // Listener on C1 and C2 $(inputs).click(function(e) { // Toggle the checkboxes in the hidden question if ($('input.radio:last', qC1).is(':checked') || $('input.radio:last', qC2).is(':checked')) { $('input.checkbox', qHidden).prop('checked', true); $('li.question-item input[type="hidden"]', qHidden).val('Y'); } else { $('input.checkbox', qHidden).prop('checked', false); $('li.question-item input[type="hidden"]', qHidden).val(''); } // Fire the array filter $('input.checkbox', qHidden).each(function(i) { checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type')); }); }); }); </script>
Here's a sample survey:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: jajas
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 2 months ago #115858
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Disabled answer in a question base on selected answer in previous question
Great solution, Tony!
Can you add that to the wiki as a Christmas present
Can you add that to the wiki as a Christmas present
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.