Check out the LimeSurvey source code on GitHub!

Move to the end of the survey

More
5 years 6 months ago #62789 by madopr
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!!

Please Log in to join the conversation.

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

Please Log in to join the conversation.

More
5 years 6 months ago #62793 by madopr
Thanx! that's what I needed. Works perfect.

Please Log in to join the conversation.

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