Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: keep order of response in a multiple choice question

keep order of response in a multiple choice question 5 years 3 weeks ago #68885

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6027
  • Thank you received: 373
  • Karma: 260
Thanks for planning to support us by donating to the project!

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'"
The administrator has disabled public write access.

keep order of response in a multiple choice question 5 years 1 week ago #69586

  • cegreja
  • cegreja's Avatar
  • Offline
  • Junior Lime
  • Posts: 25
  • Karma: 0
I'm now testing the survey and there's a little problem: if the person answering the survey checks the brands A, B and C but changes his/her mind or has made a mistake and so decides to uncheck those boxes and instead select brands D, E, F, the text appearing later on still refers to the first brands checked (A, B and C).

Is there any way to make sure this still works even if people change their original choices?

Thanks
The administrator has disabled public write access.

keep order of response in a multiple choice question 5 years 1 week ago #69591

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6567
  • Thank you received: 1477
  • Karma: 579
Replace the code in the hidden short-text with this - it will remove values from the short-text as they are unchecked.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var q1ID = 11;
		var qHidden = HH;
 
		// Hide the hidden question	
		$('#question'+qHidden+'').hide();
 
		var q1Answers = new Array();
 
		// Build an array of q1 answers checked
		$('#question'+q1ID+' input.checkbox').click(function(){
			var ansText = $(this).siblings('label').text();
			if($(this).attr('checked') == true) { // Add to array if checked
				q1Answers.push(ansText);
			}
			else { // Remove from array if unchecked
				q1Answers = jQuery.grep(q1Answers, function(element) { 
								return element != ansText; 
							});
			}
		});
 
		// Interrupt next/submit function 
		$('#movenextbtn, #movesubmitbtn').click(function(){
 
			$('#question'+qHidden+' input.text').val(q1Answers);
 
			return true;
		});
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 1 week ago by tpartner.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.213 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form