Could someone have a look at this form and guess as to why the calculation doesn't work? Or could you redirect me to a good source of help?
http://www3.telus.net/sprecious/Faulty_form.htm
The above link is a stripped-down version of my troublesome order form. I've renamed all products to remain anonymous. This form is designed to calculate an order total including taxes, which depend on your Canadian province.
Taxes are properly calculated, but the condiment total and the grand total are wrong. All functions have previously worked. Here are the two I just added (which don't work). Can anyone see any immediately obvious syntax errors?
function calculate_total()
{
switch(document.myform.state.value)
{
case "Alberta":
var gst_perc=".07";
var pst_perc=".00";
var pack_quantity =
document.myform.west_pack.value +
document.myform.prarie_pack.value +
document.myform.cent_pack.value +
document.myform.east_pack.value +
document.myform.alta_pack.value;
document.myform.map_pack_subtotal.value = calculate_map_packs(pack_quantity);
document.myform.grand_subtotal.value =
document.myform.product_subtotal.value +
document.myform.map_pack_subtotal.value;
document.myform.gst.value = document.myform.grand_subtotal.value * gst_perc;
document.myform.pst.value = document.myform.grand_subtotal.value * pst_perc;
document.myform.grand_total.value =
document.myform.grand_subtotal.value +
document.myform.gst.value +
document.myform.pst.value +
document.myform.shipping.value;
setupFields()
break
-----the switch statement repeats the above code for all 13 provinces-----
function calculate_map_packs(var1)
{
var x = 0;
switch(var1)
{
case 0:
x = 0;
break
case 1:
x = 0;
break
case 2:
x = 39.95;
break
case 3:
x = 79.90;
break
case 4:
x = 119.85;
break
case 5:
x = 159.8;
break
default:
}
return x
}
http://www3.telus.net/sprecious/Faulty_form.htm
The above link is a stripped-down version of my troublesome order form. I've renamed all products to remain anonymous. This form is designed to calculate an order total including taxes, which depend on your Canadian province.
Taxes are properly calculated, but the condiment total and the grand total are wrong. All functions have previously worked. Here are the two I just added (which don't work). Can anyone see any immediately obvious syntax errors?
function calculate_total()
{
switch(document.myform.state.value)
{
case "Alberta":
var gst_perc=".07";
var pst_perc=".00";
var pack_quantity =
document.myform.west_pack.value +
document.myform.prarie_pack.value +
document.myform.cent_pack.value +
document.myform.east_pack.value +
document.myform.alta_pack.value;
document.myform.map_pack_subtotal.value = calculate_map_packs(pack_quantity);
document.myform.grand_subtotal.value =
document.myform.product_subtotal.value +
document.myform.map_pack_subtotal.value;
document.myform.gst.value = document.myform.grand_subtotal.value * gst_perc;
document.myform.pst.value = document.myform.grand_subtotal.value * pst_perc;
document.myform.grand_total.value =
document.myform.grand_subtotal.value +
document.myform.gst.value +
document.myform.pst.value +
document.myform.shipping.value;
setupFields()
break
-----the switch statement repeats the above code for all 13 provinces-----
function calculate_map_packs(var1)
{
var x = 0;
switch(var1)
{
case 0:
x = 0;
break
case 1:
x = 0;
break
case 2:
x = 39.95;
break
case 3:
x = 79.90;
break
case 4:
x = 119.85;
break
case 5:
x = 159.8;
break
default:
}
return x
}