I am trying to use the jquery plugin to help out with a simple equation. I am working on it here:
http://www.zacharydesigns.com/sandbox/calc2.html
Right now I am trying to figure out how to get the second column, package pricing to be generated from this equation:
product price / total product price * 399.99
Here is the bit I was trying to use to generate that:
// the values are changes via the keyup event
$("input[name^=prod]").sum("keyup", "#totalSum");
$("input[name^=upgradeSum]").sum("keyup", "#totalUpgradeSum");
// the part that I cant get to work
$("input[name^=packagePricing]").calc(
// the equation to use for the calculation
"prod / totalSum * 399.99",
{
prod: $("input[@id^=prod_]"),
totalSum: ("input[@id^=totalSum]"),
},
// this function is execute after the calculation is completed, which allows us to
// add formatting to our value
function (s){
// return the number as a dollar amount
return "$" + s.toFixed(2);
},
// once all calculations are completed, we execute the code below
function ($this){
// now we get the sum() of all the values we just calculated
var sum = $this.sum();
// now that we have the grand total, we must update the screen
$("#packagePricing").text(
// round the results to 2 digits
"$" + sum.toFixed(2)
);
}
);
Thanks in advance for any help with this before my brain implodes.