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

TOPIC: Access answer in Assessment Result Message

Re: Access answer in Assessment Result Message 3 years 7 months ago #56872

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
You could store them in the same cookie but I think that would over-complicate things. If you only want to show the message if both questions are "Yes", I would check them before storing the cookie and then set the cookie to "Show" or "Hide".

So your script for the last page would be something like:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// Find the question results
		var result1 = '{INSERTANS:11111X22X33}';
		var result2 = '{INSERTANS:11111X22X34}';
 
		// Set a cookie with the Show/Hide value
		if(result1 == "Yes" && result2 == "Yes") {
			document.cookie = 'showMsg=Show';	
		else {
			document.cookie = 'showMsg=Hide';
		}
 
	})
 
</script>

And in the end message:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// A function to get the value of a cookie by name
		function getCookie (cookieName) {
			var results = document.cookie.match ('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
 
			if (results) {
				return (unescape (results[2]));
			}
			else {
				return null;
			}
		}
 
		// Hide the dynamic message
		$('.dynamicMessage').hide();
 
		// Retrieve the cookie value
		var showMsg = getCookie ('showMsg');
 
		// Display the message if the cookie is "Show"
		if(showMsg == 'Show') {
			$('.dynamicMessage').show();
		}
 
	});
 
</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.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.125 seconds
Donation Image