Welcome, Guest
Username: Password: Remember me

TOPIC: Filter List(Radio) with another List(Radio)

Filter List(Radio) with another List(Radio) 3 years 2 months ago #62870

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 51
  • Thank you received: 1
  • Karma: 0
I have a list/radio question with 7 options, I have subsequent question that I want to have the 6 remaining options that they did not select (what's your first choice... what's your second choice...)

I tried using the array exclusion but it gave me a blank list

it works of I make both of them multiple response questions but limit it to 1 response, but my boss doesn't like how it looks

suggestions?

(if anyone knows how to change the checkboxes into radio buttons, that would work too!)
The administrator has disabled public write access.

Re: Filter List(Radio) with another List(Radio) 3 years 2 months ago #62912

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 51
  • Thank you received: 1
  • Karma: 0
so I made two lists, and a hidden multiple choice question in between

when i get to the page where the hidden question lies it asks me to enter something for an answer

<p>
	&nbsp;<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// The question IDs
		var q1 = 3774;
		var qHidden = 3824;
 
		// 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);
			}
			if($('.q1Row2').attr('checked') == true) {
				$('.qHiddenRow2').attr('checked', true);
			}
			if($('.q1Row3').attr('checked') == true) {
				$('.qHiddenRow3').attr('checked', true);
			}
			if($('.q1Row4').attr('checked') == true) {
				$('.qHiddenRow4').attr('checked', true);
			}
			if($('.q1Row5').attr('checked') == true) {
				$('.qHiddenRow5').attr('checked', true);
			}
			if($('.q1Row6').attr('checked') == true) {
				$('.qHiddenRow6').attr('checked', true);
			}
			// Carry on with submit
			return true;
		});		
 
	})
 
</script></p>

but when I hit the question I get:

Please choose at least 1 answer(s) for question " $(document).ready(function(){ // The question IDs var q1 = 3774; var qHidden = 3824; // 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); } if($('.q1Row2').attr('checked') == true) { $('.qHiddenRow2').attr('checked', true); } if($('.q1Row3').attr('checked') == true) { $('.qHiddenRow3').attr('checked', true); } if($('.q1Row4').attr('checked') == true) { $('.qHiddenRow4').attr('checked', true); } if($('.q1Row5').attr('checked') == true) { $('.qHiddenRow5').attr('checked', true); } if($('.q1Row6').attr('checked') == true) { $('.qHiddenRow6').attr('checked', true); } // Carry on with submit
Last Edit: 3 years 2 months ago by vadindot.
The administrator has disabled public write access.

Re: Filter List(Radio) with another List(Radio) 3 years 2 months ago #62947

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4190
  • Thank you received: 787
  • Karma: 359
when i get to the page where the hidden question lies...
That workaround is for questions on the same page (group by group mode). You cannot use JavaScript to manipulate questions on other pages.

If your questions are on different pages (question by question mode), you will probably need to use {INSERTANS} to get the value of Q1 and then hide that option in Q2.

Something like this in the source of Q2. Replace "11111", "22" and "33" with the survey ID, group ID and Q2 question ID. Note that the answer labels for both questions must be identical.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var q1 = '{INSERTANS:11111X22X33}';
 
		$('label').filter( function (index) {
			return $(this).text() == q1;
		})
		.parent().hide().siblings('input.radio').attr('checked', false);
 
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Filter List(Radio) with another List(Radio) 3 years 2 months ago #62949

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 51
  • Thank you received: 1
  • Karma: 0
would it matter if the responses to the radio were randomized?
The administrator has disabled public write access.

Re: Filter List(Radio) with another List(Radio) 3 years 2 months ago #62950

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4190
  • Thank you received: 787
  • Karma: 359
Nope, the script just looks for a label that exactly matches the Q1 answer and hides that row in Q2 (and unchecks that radio if checked).
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Filter List(Radio) with another List(Radio) 3 years 3 weeks ago #65016

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 51
  • Thank you received: 1
  • Karma: 0
This works great for Radio buttons, I created a second line to filter two questions out of a third also!
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var q1 = '{INSERTANS:88134X1229X4383}';
 
		$('label').filter( function (index) {
			return $(this).text() == q1;
		})
		.parent().hide().siblings('input.radio').attr('checked', false);
 
 
	$(document).ready(function() {
 
		var q2 = '{INSERTANS:88134X1230X4384}';
 
		$('label').filter( function (index) {
			return $(this).text() == q2;
		})
		.parent().hide().siblings('input.checkbox').attr('checked', false);
 
	});
 
</script>

Here's my new problem:

Q1 Q2 and Q3 all have the same option list

I need it to look like this:
Q1 - List(Radio)
Q2 - List (Radio) with choice from Q1 removed
Q3 - Multiple (Checkboxes) with choice from Q1 and Q2 removed

Q2 works fine, but Q3 doesn't

Essentially this is a ranking question, Q1=Favorite, Q2=Second favorite, Q3=all the rest that you like (and I can't get them to let me use the rank question in lime)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.221 seconds
Donation Image