jQuery calculation plugin: show total in form field rather than text
Posted
by Katherine
on Stack Overflow
See other posts from Stack Overflow
or by Katherine
Published on 2010-03-31T17:33:03Z
Indexed on
2010/03/31
17:43 UTC
Read the original article
Hit count: 590
I'm embarrassed by the 'basicness' of this question, but after wasted hours, here goes.
In an effort to do something with the jQuery Calculation plugin, I am playing with the basic example of the order form on the plugin site. I want to have the grand total as a form field,rather than text, so I can use the value.
The function that calculates and shows the grand total is:
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)
);
}
the total updates on keyup in:
<span id="grandTotal"></span>
But this does not work with:
<input type="text" id="grandTotal" value=""/>
Can anyone point me to what I need to add/change to make that work? To call my javascript basic would be a compliment, so please talk to me like I know nothing!
© Stack Overflow or respective owner