how to add the sum of them all

<script type="text/javascript"> 

function AddGuestCALC(){ 
newValue = (parseInt(document.formcheck.Price.value) * parseInt(document.formcheck.Guest.value)); 
document.formcheck.AddGuestTOTAL.value = newValue; 
} 

function MenuChange(){ 
newValue = parseInt(document.formcheck.Menu.value.asInt); 
document.formcheck.Price.value = newValue; 
}

function LechonCALC(){ 
newValue = parseInt(document.formcheck.Lechon.value) * 6500; 
document.formcheck.LechonTOTAL.value = newValue; 
} 

function AmmenitiesCALC(){ 
newValue = parseInt(document.formcheck.Total.value) + 10000; 
document.formcheck.Total.value = newValue; 
} 

function BridalCALC(){ 
newValue = parseInt(document.formcheck.Bridal.value) * 1500; 
document.formcheck.BridalTOTAL.value = newValue; 
} 

function CocktailCALC(){ 
newValue = parseInt(document.formcheck.Cocktail.value) * 5000; 
document.formcheck.CocktailTOTAL.value = newValue; 
} 

function SaladCALC(){ 
newValue = parseInt(document.formcheck.Salad.value) * 5000; 
document.formcheck.SaladTOTAL.value = newValue; 
} 

function DessertCALC(){ 
newValue = parseInt(document.formcheck.Dessert.value) * 5000; 
document.formcheck.DessertTOTAL.value = newValue; 
} 

function FishCALC(){ 
newValue = parseInt(document.formcheck.Fish.value) * 4500; 
document.formcheck.FishTOTAL.value = newValue; 
} 

function LightsCALC(){ 
newValue = parseInt(document.formcheck.Lights.value) * 3000; 
document.formcheck.LightsTOTAL.value = newValue; 
} 

function FlameCALC(){ 
newValue = parseInt(document.formcheck.Flame.value) * 3000; 
document.formcheck.FlameTOTAL.value = newValue;  

}

function EventLCALC(){ 
newValue = parseInt(document.formcheck.EventL.value) * 3500; 
document.formcheck.EventLTOTAL.value = newValue;

}  

function CorkageCALC(){ 
newValue = parseInt(document.formcheck.Corkage.value) * 6500; 
document.formcheck.CorkageTOTAL.value = newValue;
}


</script> 

Recommended Answers

simply make one javascript method.return the value after each methods above and then add it.
For eg:-

function CorkageCALC(){ 
newValue = parseInt(document.formcheck.Corkage.value) * 6500; 
document.formcheck.CorkageTOTAL.value = newValue;
return newValue;
}

then make a method and add all

function SumOfAllValue(){ 
document.formcheck.SumOfAllValue.value = CorkageCALC()+EventLCALC()+....
}
Jump to Post

alert value and check the value of AddGuestCALC() before assigning value to check what value it is returning

Jump to Post

Not sure thought but check this,

instead of

document.formcheck.Corkage.value

try this

document.formcheck.elements['Corkage'].value

and then alert value of it.There is problem in your above all javascript methods.Try the way i gave,then it might work.

Jump to Post

All 9 Replies

simply make one javascript method.return the value after each methods above and then add it.
For eg:-

function CorkageCALC(){ 
newValue = parseInt(document.formcheck.Corkage.value) * 6500; 
document.formcheck.CorkageTOTAL.value = newValue;
return newValue;
}

then make a method and add all

function SumOfAllValue(){ 
document.formcheck.SumOfAllValue.value = CorkageCALC()+EventLCALC()+....
}

the sum wont show in the Total textbox

function Total()
{ 
document.formcheck.Total.value = AddGuestCALC()+LechonCALC()+BridalCALC()+CocktailCALC()+SaladCALC()+DessertCALC()+FishCALC()+LightsCALC()+EventLCALC()+CorkageCALC();
}

alert value and check the value of AddGuestCALC() before assigning value to check what value it is returning

NaN

Not sure thought but check this,

instead of

document.formcheck.Corkage.value

try this

document.formcheck.elements['Corkage'].value

and then alert value of it.There is problem in your above all javascript methods.Try the way i gave,then it might work.

no luck :(

after every javascript method,write alert to check if you are getting any value.
Press f12 in IE and start debugging your javascript by adding debug point.

not yet solved help

help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.