Can someone please help me with this calcuation? A person enters their height, length, width and weight of their parcel. The calculate button then runs the function below to calculate the volumetric weight. The total price is based on which of the two weights (normal weight entered by the user and volumetric weight) is the highest. The total price is also based on which radio box is selected, hence the “svc” code below for “Silver Service” which is $599 and “Gold Service” which is $699.
Currently this script works fine but as soon as I enter a weight of less than 10, it runs the calculation on that number instead of the higher one (volumetric) as it should. I’m sure there’s an easier way to grab the higher number of the two to run the calculation.
Please, can anybody help a total newbie??
Here’s my code:
[CODE]function compute_vol() {
var weight_calc =
(document.form.height.value*1)*
(document.form.length.value*1)*
(document.form.width.value*1)/6000;
document.form.weight_vol.value = weight_calc.toFixed(0);
if ((document.form.length.value == ”) || (document.form.width.value == ”) || (document.form.height.value == ”) || (document.form.weight.value == ”)){
alert(“In order to proceed with your order, please ensure that you’ve entered a value into all the dimension fields then click on ‘Calculate Volumetric Weight’ again.”);
document.form.Submit2.disabled = true;
return false;
}
svc = “”;
for (var i=0; i<document.form.selection.length; i++)
{if (document.form.selection[i].checked)
{svc = document.form.selection[i].value;}
}
if ((svc == “Silver Service”) && ((document.form.weight.value) > (document.form.weight_vol.value))) {
document.form.totalprice.value = (((document.form.weight.value) – 10) * 50 ) + 599;
} else if ((svc == “Silver Service”) && ((document.form.weight_vol.value) > (document.form.weight.value))) {
document.form.totalprice.value = (((document.form.weight_vol.value) – 10) * 50 ) + 599;
}
if ((svc == “Gold Service”) && ((document.form.weight.value) > (document.form.weight_vol.value))) {
document.form.totalprice.value = (((document.form.weight.value) – 10) * 50 ) + 699;
} else if ((svc == “Gold Service”) && ((document.form.weight_vol.value) > (document.form.weight.value))) {
document.form.totalprice.value = (((document.form.weight_vol.value) – 10) * 50 ) + 699;
}
Thanks!!
Karen