javascript - SQLite ROUND(X,Y) doesn't work for trailing zero when using currency values -
I display a currency value from my esclip table on my page, using the ROUND (X, Y) function That's what SQLite offers, but whenever I do something like rounds (money, 2), 0 never shows at the end. I know that it is doing two decimal places because whenever 0 result is not shown. For example: I get $ 25.35 (that's fine), but if the value is $ 25.30, then I get $ 25.3
Is there a solution?
My code for displaying values:
transaction.executeSql ('Select round (money, 2) to table1', [], function (transaction , The result) {If (result! = Null & amp; result; cry! = Null) {for (var i = 0; i & lt; result.rows.length; I ++) {var row = result.rows. Item (i); $ ('# placeonpage'). Attachments ('$' + [ROUND ('fund, 2']]]]}}}}, error handler); }, ErrorHandler, nullHandler); The round function does not return a string, it returns a number when javascript is again stringed Converts the number into, so it only uses the equivalent number of digits.
You have to format the JavaScript code:
.append ('$' + row ['money']. Toofix (2)); (In this case, you do not need to score any goals in SQL.)
Comments
Post a Comment