Hello Members,
Yes<input name="special_1" type="radio" value="1" />
No<input name="special_1" type="radio" value="0" />
<input name="total_item_1" type="text" id="total_item_1" style="text-align:right;" value="$0.00" size="7" maxlength="8" readonly="readonly">
Yes<input name="special_2" type="radio" value="1" />
No<input name="special_2" type="radio" value="0" />
<input name="total_item_2" type="text" id="total_item_2" style="text-align:right;" value="$0.00" size="7" maxlength="8" readonly="readonly">
var bIsFirebugReady = (!!window.console && !!window.console.log);
$
(document).ready(
function (){
// update the plug-in version
$
("#idPluginVersion").text($.Calculation.version);
// bind the recalc function to the quantity fields
$
("input[name^=qty_item_]").bind("keyup", recalc);
$
("input[name^=special_]").bind("checked", recalc);
// run the calculation function now
recalc
();
}
);
function recalc(){
$
("[id^=total_item]").calc(
// the equation to use for the calculation
"qty * price * special",
// define the variables used in the equation, these can be a jQuery object
{
qty
: $("input[name^=qty_item_]"),
price
: $("[id^=price_item_]"),
special
: $("input[name^=special_]")
},
// define the formatting callback, the results of the calculation are passed to this function
function (s){
// return the number as a dollar amount
return "$" + s.toFixed(2);
},
// define the finish callback, this runs after the calculation has been complete
function ($this){
// sum the total of the $("[id^=total_item]") selector
var sum = $this.sum();
$
("#grandTotal").val(
// round the results to 2 digits
"$" + sum.toFixed(2)
);
}
);
}