jQuery Auto Calculation Question!!!
I have a jQuery auto calculation script, which dynamically calculates a row total then finally SUMs the grand total, and I need to add just two features to it.
- 1st feature: How can I assign a read-only textbox for the "Grand Total"?
- 2nd feature: How can I auto-calculate the "buy used?" column, and reflect the result in the sub-total column?
You can view and download the script example here
http://www.mugnets.com/calcscript/
To use: Just type in any number into the "Qty" field, and you will see the auto-calculation work.
First, the Grand Total is associated to display to an ID tag, but I want to re-associate the Grand Total to display to a read-only input box.
function ($this){
// sum the total of the $("[id^=total_item]") selector
var sum = $this.sum();
$("#grandTotal").text(
// round the results to 2 digits
"$" + sum.toFixed(2)
);
}
Second,
the price and quantity is calculated dynamically. I would like to add the "buy used" discount item to it also. Here is the modification that I would like to get to work
// the equation to use for the calculation
"qty * price * discount",
// define the variables used in the equation, these can be a jQuery object
{
qty: $("input[name^=qty_item_]"),
price: $("[id^=price_item_]"),
discount: $("[id^=special_]")
},