My form is configured to pop up an alert box when conditions are met. In the first function allotment, the alert box appears twice. I don't know why this would be.
$(document).ready(function() {
$("#Field20").on('change', allotment);
$("#Field47").on('change', evaluate);
function allotment(){
var ToDate = $('.ToDate input').val();
var house = $('.total input').val();
switch (true){
case house == 1:
var allow = 50;
break;
case house == 2:
allow = 65;
break;
case house == 3:
allow = 80;
break;
case house == 4:
allow = 95;
break;
case house >= 5:
allow = 110;
break;
}
var availablePoints = +allow - +ToDate;
alert("This guest has " + availablePoints + "/" + allow + " points remaining this week.");
return false;
}
function evaluate(){
var house = $('.total input').val();
var cart = $('.cart input').val();
var savedCount = $('.ToDate input').val();
var newCount = +cart + +savedCount;
if (house == 1 && newCount < 50) {
alert("After today, there are " + (50 - newCount)
+ " food points remaining for the week.");
} else if (house == 2 && newCount < 65) {
alert("After today, there are " + (65 - newCount)
+ " food points remaining for the week.");
} else if (house == 3 && newCount < 80) {
alert("After today, there are " + (80 - newCount)
+ " food points remaining for the week.");
} else if (house == 4 && newCount < 95) {
alert("After today, there are " + (95 - newCount)
+ " food points remaining for the week.");
} else if (house >= 5 && newCount < 110) {
alert("After today, there are " + (110 - newCount)
+ " food points remaining for the week.");
} else {
alert("The maximum number of food points have been reached.");
}
}
});