Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Move to the end of the survey

Move to the end of the survey 5 years 3 weeks ago #62789

  • madopr
  • madopr's Avatar
  • Offline
  • Junior Lime
  • Posts: 26
  • Karma: 0
Hello, I need to end a survey if some conditions occur. Something like this:
<script>
function validation()
{
    if ('{INSERTANS:72611X131X1667}'=='ASDF')
    {
	alert("You don't have the needed profile for this survey.");
	///Move to the end of the survey;        
    }
}
</script>

I tried with this:
<script>
function validation()
{
    if ('{INSERTANS:72611X131X1667}'=='ASDF')
    {
	alert("You don't have the needed profile for this survey.");
	document.limesurvey.move.value = 'movelast';
        document.limesurvey.submit();
    }
}
 
setTimeout("validation()",250);
 
</script>

in the text of the next section of the question 72611X131X1667; but it doesn't work. It just stucks in this section and keeps showing me the alert indefinitely.

Thanx for the help!!
The administrator has disabled public write access.

Move to the end of the survey 5 years 3 weeks ago #62791

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6114
  • Thank you received: 1356
  • Karma: 532
Why not use a quota - docs.limesurvey.org/quotas&structure=Eng...tions+for+LimeSurvey?

Your script is set to fire every 1/4 second, it only needs to fire once after the page loads. It also and moves the survey back, not forward. Try:
<script type="text/javascript" charset="utf-8">
 
	// Validation function
	function validation() {
		if ('{INSERTANS:72611X131X1667}'=='ASDF') {
			alert("You don't have the needed profile for this survey.");
			document.limesurvey.move.value = 'movesubmit';
			document.limesurvey.submit();
		}
	}
 
	// Wait for the page to load...
	$(document).ready(function() {
 
		// Okay, now call the validation function
		validation();
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Move to the end of the survey 5 years 3 weeks ago #62793

  • madopr
  • madopr's Avatar
  • Offline
  • Junior Lime
  • Posts: 26
  • Karma: 0
Thanx! that's what I needed. Works perfect.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.253 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form