Hi, I currently have a calculator on my webpage which calculates the total cost of items to be purchased.
There is a function calc() which goes like this:
I'm after another formula which calculates the overall delivery cost for an order. However, it's a bit tricky.
The two items listed here is a 'bat' and 'wickets'. If you order one bat, the delivery charge is $3.00 and for every extra additional bat the charge is $1.00. Wickets delivery charge is $6.00 for one and $2.00 for additional purchases.
I'm looking for code which does this:
Totals the delivery charge based on the quantity ordered. For example if three bats and three wickets are ordered, the delivery charge should equal $15.00 ($5.00 for bat and $10.00 for Wickets).
I guess you would need an IF Function but I have no idea how to code it. Any help would be great. Thanks, JL :)
There is a function calc() which goes like this:
Code:
function calc()
{
sum=parseFloat(document.getElementById('bat').value.substr(1))
+parseFloat(document.getElementById('wickets').value.substr(1));
document.getElementById('total').value='$'+sum.toFixed(2);
The two items listed here is a 'bat' and 'wickets'. If you order one bat, the delivery charge is $3.00 and for every extra additional bat the charge is $1.00. Wickets delivery charge is $6.00 for one and $2.00 for additional purchases.
I'm looking for code which does this:
Totals the delivery charge based on the quantity ordered. For example if three bats and three wickets are ordered, the delivery charge should equal $15.00 ($5.00 for bat and $10.00 for Wickets).
I guess you would need an IF Function but I have no idea how to code it. Any help would be great. Thanks, JL :)