I have a function that calculates price when the user inputs a quantity that works perfectly. Here it is:
However, the function requires a whole, positive number to work. I would like to have an alert that pops up if any of the following occurs as part of the IF statement in the function:
1: If the number is negative. or in not a whole number, and
2: If the number is not devisible by 25 (meaning, if IF(qnty/25<>INT(qnty/25))
How do I include these "IFs" in the function?
Thanks
Code:
function STWCORPrice() {
var price = 0;
var shipping = 0;
var total=0;
var productcost=0;
var qnty=0;
var stwqnty=document.getElementById("STWquant").value;
var corqnty=document.getElementById("CORquant").value;
qnty = (stwqnty*1) + (corqnty*1);
if (qnty > 49 && qnty < 75){
shipping = 6.25;
price = .23;
}
else if (qnty > 74 && qnty < 100){
shipping = 6.25;
price = .17;
}
else if (qnty > 99 && qnty < 3000){
shipping = 21;
price = .0925;
}
else if (qnty > 2999 && qnty < 4000){
shipping = 27;
price = .0925;
}
productcost = price * qnty;
total = productcost + shipping;
document.all('qnty').innerHTML= qnty.toFixed(0);
document.all('productcost').innerHTML= '$ '+ productcost.toFixed(2);
document.all('shipping').innerHTML= '$ '+ shipping.toFixed(2);
document.all('total').innerHTML= '$ '+ total.toFixed(2);
}
1: If the number is negative. or in not a whole number, and
2: If the number is not devisible by 25 (meaning, if IF(qnty/25<>INT(qnty/25))
How do I include these "IFs" in the function?
Thanks
Comment