Check out the LimeSurvey source code on GitHub!

keep order of response in a multiple choice question

More
5 years 3 months ago #68885 by Mazi
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'"

Please Log in to join the conversation.

More
5 years 3 months ago #69586 by cegreja
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

Please Log in to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #69591 by tpartner
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 3 months ago by tpartner.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form