I have a javascript that adds up inputs from a form. When the total is >= 110 it sends an alert that the total can not be over 100. This all works, but after the alert the form option stays at the value that put the total over 100. How do I only reset the variable that is changing, not all the variables?
Here is the code for the function.
Hope someone can help.
Yours,
Dale Rose
Here is the code for the function.
Code:
//Calculates the total of all selections
function GetTotal()
{
//get variables from form and makes them integers
var Ami = parseInt(document.voting.Ami.value);
var Chad = parseInt(document.voting.Chad.value);
var Chris = parseInt(document.voting.Chris.value);
var Eliza = parseInt(document.voting.Eliza.value);
var John_K = parseInt(document.voting.John_K.value);
var Julie = parseInt(document.voting.Julie.value);
var Lea = parseInt(document.voting.Lea.value);
var Leann = parseInt(document.voting.Leann.value);
var Lisa = parseInt(document.voting.Lisa.value);
var Rory = parseInt(document.voting.Rory.value);
var Scout = parseInt(document.voting.Scout.value);
var Twila = parseInt(document.voting.Twila.value);
//adds all variables together to get total
var Gtotal = Ami + Chad + Chris + Eliza + John_K + Julie + Lea + Leann + Lisa + Rory + Scout + Twila;
//makes the form element total equal to variable total
if (Gtotal >= 110){
alert('Total can not be more than 100!');
}
else {
document.voting.total.value = Gtotal;
}
}
Hope someone can help.
Yours,
Dale Rose