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

TOPIC: Answer options based on previous question

Answer options based on previous question 3 years 1 week ago #91796

Thanks a lot Tony :) .
The administrator has disabled public write access.

Answer options based on previous question 2 months 3 weeks ago #128545

  • mmsurveys
  • mmsurveys's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hello, I have a another question based on this situation.
How do I do this if the questions are not on the same page? (So If I display the questions page per page).
Question 1 lets the user choose the course
Question 2 lets the user select the teacher which is possible for the selected course?

Can you please give me a shot example?!
Many thanks in advance!
The administrator has disabled public write access.

Answer options based on previous question 2 months 2 weeks ago #128562

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5398
  • Thank you received: 1149
  • Karma: 477
Assuming both questions are single-choice radios, remove the script from Q1 and add something like this to Q2:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// The Q2 options corresponding to the Q1 options		
		teacherLists = {
			C1 : 'T1,T3,T5',
			C2 : 'T1,T2,T3,T4',
			C3 : 'T2,T3,T4,T5',
			C4 : 'T1,T4,T6'
		};
 
		// Identify this question
		var thisQuestion = $('#question{QID}')
 
		// The checked option in Q1
		var q1Ans = '{Q1}';
 
		// Hide all of the teachers
		$('li[id^="javatbd"]', thisQuestion).hide();
 
		// Now show the appropriate ones
		$(teacherLists[q1Ans].split(',')).each(function(i){
			$('input.radio[id$="'+{QID}+this+'"]').closest('li').show();
		});
 
		// Uncheck all hidden radios (in case page has been seen before)
		$('li[id^="javatbd"]:hidden input.radio', thisQuestion).prop('checked', false);
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...2(1).lss
File Size:16 KB
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.

Answer options based on previous question 2 months 2 weeks ago #128563

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8194
  • Thank you received: 1117
  • Karma: 331
Hi,

I use another method, using an "multiple choice" and check it acording to selection : demonstration.sondages.pro/676785#
The administrator has disabled public write access.

Answer options based on previous question 2 months 2 weeks ago #128566

  • mmsurveys
  • mmsurveys's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thank you very much Tony!!! This should do the job!
The administrator has disabled public write access.

Answer options based on previous question 2 months 2 weeks ago #128567

  • mmsurveys
  • mmsurveys's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hey Denis, thank you for the suggestion. unfortunately, I'm a bit confused due to my lack of speaking French :/
Tonys version should work. If not, I'll come again and try the translator or just ask ;)
Many thanks to you!
The administrator has disabled public write access.

Answer options based on previous question 2 months 2 weeks ago #128572

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8194
  • Thank you received: 1117
  • Karma: 331
Hi, Tnoy solution was perfect :) and it work. Just to show alternatives :)
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.152 seconds