i have table head <th> set default 0:
<th id="total_price" style="text-align:center">0</th> now when, add new sold item, price should added value of <th>. so, if new 1 20000, value should 20000+0=20000 , not 200000. , if add item, price of 30 000 20000030 000.
this jquery script:
var initial = $("#total_price").text(); console.log(initial); var newprice = initial + (res['price']); console.log(newprice); $("#total_price").text(newprice); i tried this:
var initial = $("#total_price").text(); console.log(initial); var newprice = initial + +(res['price']); console.log(newprice); $("#total_price").text(newprice); but still same.
you need parse text (string) integer , add up. below calculations
var newprice = parseint(initial,10) + parseint(res['price'],10); or else what trying string concatenation , not sum
you can more info here

Comments
Post a Comment