Disabled answer in a question base on selected answer in previous question

More
2 years 11 months ago #115735 by jajas
jajas created the topic: Disabled answer in a question base on selected answer in previous question
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

Please Log in to join the conversation.

More
2 years 11 months ago - 2 years 11 months ago #115766 by tpartner
tpartner replied the 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: 2 years 11 months ago by tpartner.

Please Log in to join the conversation.

More
2 years 11 months ago #115769 by jajas
jajas replied the topic: Disabled answer in a question base on selected answer in previous question
Can you give me a sample, Please?

Please Log in to join the conversation.

More
2 years 11 months ago #115770 by tpartner
tpartner replied the 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.

Please Log in to join the conversation.

More
2 years 11 months ago #115790 by jajas
jajas replied the topic: Disabled answer in a question base on selected answer in previous question
I think it's different case. hmmm...

Please Log in to join the conversation.

More
2 years 11 months ago #115832 by Bigred01
Bigred01 replied the 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...
$(document).ready(function() {
 
var prevAns =  "{C1.NAOK} "  === "2"  &&  "{C2.NAOK} "  === "2" ;
 
if(prevAns) {
     $(".radio:eq(2),.radio:eq(3)").attr("disabled",true);
}
});

Please Log in to join the conversation.

More
2 years 11 months ago #115833 by jajas
jajas replied the 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.

Please Log in to join the conversation.

More
2 years 11 months ago #115835 by tpartner
tpartner replied the topic: Disabled answer in a question base on selected answer in previous question

I think it's different case. hmmm...

Here is an example for your situation.

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.

<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:

File Attachment:

File Name: limesurvey...4176.lss
File Size:19 KB

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

Please Log in to join the conversation.

More
2 years 11 months ago #115858 by Mazi
Mazi replied the 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 :-)


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!