Hiding responses on a mult choice question based on a single choice

More
2 years 9 months ago #117697 by vadindot
vadindot created the topic: Hiding responses on a mult choice question based on a single choice
I recently switched over to 2.0.5, and an old questionnaire of mine no longer works.

I have a question (q1) that has a list of 36 locations.
I have a question (q7) that has 26 items, which vary because each of the different locations may have a separate subset of them.

What I used to use (thanks to tpartner) is a hidden question underneath q1 which would check off the items that each location might have, and then that would filter q7. Unfortunately, it is not working. Here is the javascript that would go into the question, I was wondering if anyone can help me update it.
 <script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
                //THIS IS THE AT-CENTER VERSION
		// The question IDs
		var q1 = 1;
		var qHidden = 40;
 
		// Hide the hidden question
		$('#question'+qHidden+'').hide();
 
		// Assign classes to the inputs
		$('#question'+q1+' input.radio').each(function(i) {
			$(this).addClass('q1Row'+(i+1)+'');
		});
		$('#question'+qHidden+' input.checkbox').each(function(i) {
			$(this).addClass('qHiddenRow'+(i+1)+'');
		});
 
		// Interrupt the Next/Submit function
		$('form#limesurvey').submit(function(){
 
			// Reset the hidden question
			$('#question'+qHidden+' input.checkbox').attr('checked', false);
 
			// If q1 row 1 is checked we do this
			if($('.q1Row1').attr('checked') == true) {
				$('.qHiddenRow1').attr('checked', true);
				$('.qHiddenRow2').attr('checked', true);
				$('.qHiddenRow3').attr('checked', false);
				$('.qHiddenRow4').attr('checked', true);
			}
			if($('.q1Row2').attr('checked') == true) {
				$('.qHiddenRow1').attr('checked', false);
				$('.qHiddenRow2').attr('checked', true);
				$('.qHiddenRow3').attr('checked', true);
				$('.qHiddenRow4').attr('checked', true);
			}
 
			// Carry on with submit
			return true;
		});		
 
	})
 
</script>

Please Log in to join the conversation.

More
2 years 9 months ago #117708 by tpartner
tpartner replied the topic: Hiding responses on a mult choice question based on a single choice
Replace all instances of:
.attr('checked'

With:
.prop('checked'

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: vadindot

Please Log in to join the conversation.

More
2 years 9 months ago #117784 by vadindot
vadindot replied the topic: Hiding responses on a mult choice question based on a single choice
That would be it

Thanks Tony!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!