Welcome, Guest
Username: Password: Remember me

TOPIC: Move to the end of the survey

Move to the end of the survey 4 years 2 months 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 4 years 2 months ago #62791

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5095
  • Thank you received: 1047
  • Karma: 440
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Move to the end of the survey 4 years 2 months 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.125 seconds