jQuery Auto Calculation Question!!!

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.






  1. function ($this){
  2.  // sum the total of the $("[id^=total_item]") selector
  3.  var sum = $this.sum(); 
  4.  $("#grandTotal").text(
  5.  // round the results to 2 digits
  6.  "$" + sum.toFixed(2)
  7.  );
  8. }

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
  1. // the equation to use for the calculation
  2. "qty * price * discount",
  3. // define the variables used in the equation, these can be a jQuery object
  4. {
  5.  qty: $("input[name^=qty_item_]"),
  6.  price: $("[id^=price_item_]"),
  7.  discount: $("[id^=special_]")
  8. },