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

TOPIC: Compute value in question

Re: Compute value in question 2 years 5 months ago #68320

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3844
  • Thank you received: 690
  • Karma: 330
Okay, but I still think you should move mp2 (the quota question) to another group because p2 may not be shown (depending on conditions) and that would leave an empty page shown.
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: Compute value in question 2 years 5 months ago #68326

  • rafael_ur
  • rafael_ur's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 74
  • Karma: 0
OK Toni,
've changed the thing to the next page shows the blank page buts How I can do to jump to the next page (now empty)?
Sending the file.


Thank,
Rafael
Attachments:
The administrator has disabled public write access.

Re: Compute value in question 2 years 5 months ago #68327

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3844
  • Thank you received: 690
  • Karma: 330
That makes it easier - we can use {INSERTANS} to get the answers for p1 and p2.

So, in mp2, we add a script that does the following:
- hides the <body> element
- finds if "FIAT" was selected in p1 or p2
- clicks the appropriate radio in mp2
- automatically submits the group
Note that the SGQA values in this script will be different from yours when you import the attached sample survey.
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){  	
		// Get p1 and p2 answers
		var p1Ans = "{INSERTANS:35779X963X122822}";  	
		var p2Ans = "{INSERTANS:35779X964X122842}";
 
		// Hide the <body> element so user sees less flash
		$('body').hide();
 
		// Set the radio question
		if (p1Ans == 'FIAT' || p2Ans == 'FIAT') {
			$('.yes-no:eq(0) input.radio:eq(0)').attr('checked', true);	
		}
		else  {
			$('.yes-no:eq(0) input.radio:eq(1)').attr('checked', true);	
		}
 
		// Advance in the survey
		document.limesurvey.move.value = 'movenext';
		document.limesurvey.submit();        
 
	});
</script>

Then in p3, we need to add a small script to allow skipping of the previous hidden group so respondents can go back in the survey:
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){ 
 
		// Skip previous group
		$('#moveprevbtn').mousedown(function () { 
			$('#thisstep').val($('#thisstep').val() - 1);
		});
 
	});
</script>

Here is the sample survey with the new code in mp2 and p3:

File Attachment:

File Name: p1p2_v2_TONY.lss
File Size: 37 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.

Re: Compute value in question 2 years 5 months ago #68328

  • rafael_ur
  • rafael_ur's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Tony,

Many thanks for your help, good job (I'm going to contribute to support).

Rafael
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.105 seconds
Donation Image