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

TOPIC: keep order of response in a multiple choice question

keep order of response in a multiple choice question 4 years 3 months ago #68885

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5841
  • Thank you received: 348
  • Karma: 261
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)limesurvey.org'"
The administrator has disabled public write access.

keep order of response in a multiple choice question 4 years 2 months 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 4 years 2 months ago #69591

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5416
  • Thank you received: 1154
  • Karma: 479
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 4 years 2 months ago by tpartner.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.149 seconds