Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Filtering some answers from an array

Re: Filtering some answers from an array 3 years 9 months ago #56871

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 52
  • Thank you received: 1
  • Karma: 0
okay Tony... that last thing was absolutely perfect... do you think you could come up with a way of doing the same exact thing with a token field instead of a question?
The administrator has disabled public write access.

Re: Filtering some answers from an array 3 years 9 months ago #56876

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
This is not tested but should work:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// The question IDs
		var qHidden = HH;
 
		// Hide the hidden question
		$('#question'+qHidden+'').hide();
 
		// Assign classes to the inputs
		$('#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 token 1 is one value we do this
			if('{TOKEN:ATTRIBUTE_1}' == 'Value 1') {
				$('.qHiddenRow2').attr('checked', true);
				$('.qHiddenRow3').attr('checked', true);
			}
			// If token 1 is another value we do this
			if('{TOKEN:ATTRIBUTE_1}' == 'Value 1') {
				$('.qHiddenRow1').attr('checked', true);
				$('.qHiddenRow2').attr('checked', true);
				$('.qHiddenRow3').attr('checked', true);
			}
			// Add more IF statements as required...
 
			// Carry on with submit
			return true;
		});		
 
	})
 
</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: Filtering some answers from an array 3 years 8 months ago #58329

  • vadindot
  • vadindot's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 52
  • Thank you received: 1
  • Karma: 0
Tony,

that I have had a chance to fully test it out, both of these solutions you gave me worked perfectly

Thanks again
The administrator has disabled public write access.

Re: Filtering some answers from an array 3 years 1 month ago #66850

  • livingview
  • livingview's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
What about if the first Question was an Array (so both questions are an Array). The second question only picks subquestions that had Option 1 & 2 in their answers to display? Thanks in advance! :)
The administrator has disabled public write access.

Re: Filtering some answers from an array 3 years 1 month ago #66851

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
I'm afraid i don't understand. Could you please expand on your requirements?
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: Filtering some answers from an array 3 years 1 month ago #66857

  • livingview
  • livingview's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Question 1: Array

Rate which of these ou like?

Great Good Ok Bad
Blue
Red
Orange
Black

If they pick Great in (Blue and Orange). I want only Blue and Orange to be in question 2. If they pick Good, Ok or Bad, then don't show it in question 2.

Question 2: Array

Rate which is most essential
Most Very Maybe
Blue
Orange

Does that make sense?

Thanks so much!
The administrator has disabled public write access.

Re: Filtering some answers from an array 3 years 1 month ago #66882

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
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: Filtering some answers from an array 3 years 1 month ago #66985

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
Perhaps you can achieve most of this (no filtering though) when using the dual scale question type.
All other solutions require some custom Javascript coding.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.134 seconds
Donation Image