vertronics
07-12-2002, 05:26 PM
Hi, I am editing a Javascript which calcutates several totals. This worked fine until I add new variables for child and adult individual skiing days. Can someone tell me what's wrong with the new script?
This script works:
<script language="javascript">
function calculateTotals() {
var form = document.orderForm;
// NOTE: child totals
form.child6Total.value = form.child6Quantity.value * form.child6RegularRate.value;
form.child5Total.value = form.child5Quantity.value * form.child5RegularRate.value;
form.child4Total.value = form.child4Quantity.value * form.child4RegularRate.value;
// NOTE: adult totals
form.adult6Total.value = form.adult6Quantity.value * form.adult6RegularRate.value;
form.adult5Total.value = form.adult5Quantity.value * form.adult5RegularRate.value;
form.adult4Total.value = form.adult4Quantity.value * form.adult4RegularRate.value;
// NOTE: senior totals
form.seniorTotal.value = form.seniorQuantity.value * form.seniorRegularRate.value;
// NOTE: sub-totals for child
// form.childGrandSkiingDays.value =
// (form.child6Quantity.value * 6)
// + (form.child5Quantity.value * 5)
// + (form.child4Quantity.value * 4);
form.childGrandQuantity.value =
(form.child6Quantity.value * 1)
+ (form.child5Quantity.value * 1)
+ (form.child4Quantity.value * 1);
form.childGrandTotal.value = (form.child6Total.value * 1)
+ (form.child5Total.value * 1)
+ (form.child4Total.value * 1);
// NOTE: sub-totals for adult
// form.adultGrandSkiingDays.value = (form.adult6Quantity.value * 6)
// + (form.adult5Quantity.value * 5)
// + (form.adult4Quantity.value * 4);
form.adultGrandQuantity.value = (form.adult6Quantity.value * 1)
+ (form.adult5Quantity.value * 1)
+ (form.adult4Quantity.value * 1);
form.adultGrandTotal.value = (form.adult6Total.value * 1)
+ (form.adult5Total.value * 1)
+ (form.adult4Total.value * 1);
// NOTE: grand total of days
// form.grandSkiingDays.value = (form.infantNumberOfDays.value * form.infantQuantity.value)
// + (form.childGrandSkiingDays.value * 1)
// + (form.adultGrandSkiingDays.value * 1);
// NOTE: grand total of tickets
form.grandQuantity.value = (form.childGrandQuantity.value * 1)
+ (form.adultGrandQuantity.value * 1)
+ (form.seniorQuantity.value * 1);
// NOTE: grand $ total
form.grandTotal.value = (form.childGrandTotal.value * 1)
+ (form.adultGrandTotal.value * 1)
+ (form.seniorTotal.value * 1);
}
</script>
:confused:
This is the new script which causes my grandTotals to fail (
the totals don't show up)
<script language="javascript">
function calculateTotals() {
var form = document.orderForm;
// NOTE: child totals
form.child6Total.value = form.child6Quantity.value * form.child6RegularRate.value;
form.child5Total.value = form.child5Quantity.value * form.child5RegularRate.value;
form.child4Total.value = form.child4Quantity.value * form.child4RegularRate.value;
// NOTE: adult totals
form.adult6Total.value = form.adult6Quantity.value * form.adult6RegularRate.value;
form.adult5Total.value = form.adult5Quantity.value * form.adult5RegularRate.value;
form.adult4Total.value = form.adult4Quantity.value * form.adult4RegularRate.value;
// NOTE: senior totals
form.seniorTotal.value = form.seniorQuantity.value * form.seniorRegularRate.value;
// NOTE: sub-totals for child
// form.childGrandSkiingDays.value =
// (form.child6Quantity.value * 6)
// + (form.child5Quantity.value * 5)
// + (form.child4Quantity.value * 4);
// NOTE: totals for child individual skiing days
// form.childSkiingDays6.value = (form.child6Quantity.value * 1);
// form.childSkiingDays5.value = (form.child5Quantity.value * 1);
//form.childSkiingDays4.value = (form.child4.Quantity.value * 1);
form.childGrandQuantity.value =
(form.child6Quantity.value * 1)
+ (form.child5Quantity.value * 1)
+ (form.child4Quantity.value * 1);
form.childGrandTotal.value = (form.child6Total.value * 1)
+ (form.child5Total.value * 1)
+ (form.child4Total.value * 1);
// NOTE: sub-totals for adult
// form.adultGrandSkiingDays.value = (form.adult6Quantity.value * 6)
// + (form.adult5Quantity.value * 5)
// + (form.adult4Quantity.value * 4);
// NOTE: totals for adult individual skiing days
// form.adultSkiingDays6.value = (form.adult6Quantity.value * 1);
// form.adultSkiingDays5.value = (form.adult5Quantity.value * 1);
//form.adultSkiingDays4.value = (form.adult4Quantity.value * 1);
form.adultGrandQuantity.value = (form.adult6Quantity.value * 1)
+ (form.adult5Quantity.value * 1)
+ (form.adult4Quantity.value * 1);
form.adultGrandTotal.value = (form.adult6Total.value * 1)
+ (form.adult5Total.value * 1)
+ (form.adult4Total.value * 1);
// NOTE: grand total of days
// form.grandSkiingDays.value = (form.infantNumberOfDays.value * form.infantQuantity.value)
// + (form.childGrandSkiingDays.value * 1)
// + (form.adultGrandSkiingDays.value * 1);
// NOTE: grand total of tickets
form.grandQuantity.value = (form.childGrandQuantity.value * 1)
+ (form.adultGrandQuantity.value * 1)
+ (form.seniorQuantity.value * 1);
// NOTE: grand $ total
form.grandTotal.value = (form.childGrandTotal.value * 1)
+ (form.adultGrandTotal.value * 1)
+ (form.seniorTotal.value * 1);
}
</script>
Thanks in advance!
~cherylw
This script works:
<script language="javascript">
function calculateTotals() {
var form = document.orderForm;
// NOTE: child totals
form.child6Total.value = form.child6Quantity.value * form.child6RegularRate.value;
form.child5Total.value = form.child5Quantity.value * form.child5RegularRate.value;
form.child4Total.value = form.child4Quantity.value * form.child4RegularRate.value;
// NOTE: adult totals
form.adult6Total.value = form.adult6Quantity.value * form.adult6RegularRate.value;
form.adult5Total.value = form.adult5Quantity.value * form.adult5RegularRate.value;
form.adult4Total.value = form.adult4Quantity.value * form.adult4RegularRate.value;
// NOTE: senior totals
form.seniorTotal.value = form.seniorQuantity.value * form.seniorRegularRate.value;
// NOTE: sub-totals for child
// form.childGrandSkiingDays.value =
// (form.child6Quantity.value * 6)
// + (form.child5Quantity.value * 5)
// + (form.child4Quantity.value * 4);
form.childGrandQuantity.value =
(form.child6Quantity.value * 1)
+ (form.child5Quantity.value * 1)
+ (form.child4Quantity.value * 1);
form.childGrandTotal.value = (form.child6Total.value * 1)
+ (form.child5Total.value * 1)
+ (form.child4Total.value * 1);
// NOTE: sub-totals for adult
// form.adultGrandSkiingDays.value = (form.adult6Quantity.value * 6)
// + (form.adult5Quantity.value * 5)
// + (form.adult4Quantity.value * 4);
form.adultGrandQuantity.value = (form.adult6Quantity.value * 1)
+ (form.adult5Quantity.value * 1)
+ (form.adult4Quantity.value * 1);
form.adultGrandTotal.value = (form.adult6Total.value * 1)
+ (form.adult5Total.value * 1)
+ (form.adult4Total.value * 1);
// NOTE: grand total of days
// form.grandSkiingDays.value = (form.infantNumberOfDays.value * form.infantQuantity.value)
// + (form.childGrandSkiingDays.value * 1)
// + (form.adultGrandSkiingDays.value * 1);
// NOTE: grand total of tickets
form.grandQuantity.value = (form.childGrandQuantity.value * 1)
+ (form.adultGrandQuantity.value * 1)
+ (form.seniorQuantity.value * 1);
// NOTE: grand $ total
form.grandTotal.value = (form.childGrandTotal.value * 1)
+ (form.adultGrandTotal.value * 1)
+ (form.seniorTotal.value * 1);
}
</script>
:confused:
This is the new script which causes my grandTotals to fail (
the totals don't show up)
<script language="javascript">
function calculateTotals() {
var form = document.orderForm;
// NOTE: child totals
form.child6Total.value = form.child6Quantity.value * form.child6RegularRate.value;
form.child5Total.value = form.child5Quantity.value * form.child5RegularRate.value;
form.child4Total.value = form.child4Quantity.value * form.child4RegularRate.value;
// NOTE: adult totals
form.adult6Total.value = form.adult6Quantity.value * form.adult6RegularRate.value;
form.adult5Total.value = form.adult5Quantity.value * form.adult5RegularRate.value;
form.adult4Total.value = form.adult4Quantity.value * form.adult4RegularRate.value;
// NOTE: senior totals
form.seniorTotal.value = form.seniorQuantity.value * form.seniorRegularRate.value;
// NOTE: sub-totals for child
// form.childGrandSkiingDays.value =
// (form.child6Quantity.value * 6)
// + (form.child5Quantity.value * 5)
// + (form.child4Quantity.value * 4);
// NOTE: totals for child individual skiing days
// form.childSkiingDays6.value = (form.child6Quantity.value * 1);
// form.childSkiingDays5.value = (form.child5Quantity.value * 1);
//form.childSkiingDays4.value = (form.child4.Quantity.value * 1);
form.childGrandQuantity.value =
(form.child6Quantity.value * 1)
+ (form.child5Quantity.value * 1)
+ (form.child4Quantity.value * 1);
form.childGrandTotal.value = (form.child6Total.value * 1)
+ (form.child5Total.value * 1)
+ (form.child4Total.value * 1);
// NOTE: sub-totals for adult
// form.adultGrandSkiingDays.value = (form.adult6Quantity.value * 6)
// + (form.adult5Quantity.value * 5)
// + (form.adult4Quantity.value * 4);
// NOTE: totals for adult individual skiing days
// form.adultSkiingDays6.value = (form.adult6Quantity.value * 1);
// form.adultSkiingDays5.value = (form.adult5Quantity.value * 1);
//form.adultSkiingDays4.value = (form.adult4Quantity.value * 1);
form.adultGrandQuantity.value = (form.adult6Quantity.value * 1)
+ (form.adult5Quantity.value * 1)
+ (form.adult4Quantity.value * 1);
form.adultGrandTotal.value = (form.adult6Total.value * 1)
+ (form.adult5Total.value * 1)
+ (form.adult4Total.value * 1);
// NOTE: grand total of days
// form.grandSkiingDays.value = (form.infantNumberOfDays.value * form.infantQuantity.value)
// + (form.childGrandSkiingDays.value * 1)
// + (form.adultGrandSkiingDays.value * 1);
// NOTE: grand total of tickets
form.grandQuantity.value = (form.childGrandQuantity.value * 1)
+ (form.adultGrandQuantity.value * 1)
+ (form.seniorQuantity.value * 1);
// NOTE: grand $ total
form.grandTotal.value = (form.childGrandTotal.value * 1)
+ (form.adultGrandTotal.value * 1)
+ (form.seniorTotal.value * 1);
}
</script>
Thanks in advance!
~cherylw