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

TOPIC: Sum values different questions

Re: Sum values different questions 3 years 1 month ago #58294

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3820
  • Thank you received: 683
  • Karma: 328
You shouldn't need it with a multi-numeric - there is a built-in max/min setting:

Untitled-3_2011-03-15.png
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: Sum values different questions 3 years 1 month ago #58347

  • rocio
  • rocio's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 34
  • Karma: 0
Hello,
I have a multiple numerical input, and maximum and minimum value does not work, because if the sum gives me 20%, and is within these values ​​let you continue. I want the sum is equal to zero or 100, but no other value, so I wanted to use the script to do that identifiers eso.Pero I have to wear?
Thanks.
The administrator has disabled public write access.

Re: Sum values different questions 3 years 1 month ago #58444

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 3820
  • Thank you received: 683
  • Karma: 328
Sorry to take so long to reply Steven.

This will tally all of the inputs in a multiple numbers question and prevent survey advancing unless the tally is 0 or 100. (replace "11" with the multi-numbers ID)
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){ 
 
		$('form#limesurvey').submit(function(){
 
			var qID = 11;
 
			var totalSum = 0;
 
			// Tally up all inputs
			$('#question'+qID+' input.text').each(function(i) {
				var inputVal = $(this).val();
				if (inputVal) {
					totalSum = Number(totalSum) + Number(inputVal);
				}
			});
 
			if(totalSum == 0 || totalSum == 100) {
				return true;
			}
			else {
				return false;
			}
		});
	});
 
</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.

Re: Sum values different questions 3 years 1 month ago #58487

  • steven8000
  • steven8000's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
thanks!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.124 seconds
Donation Image