javascript - jQuery Calculation Plugin - Simple Advice Needed -
There is a simple question, but I can not understand it.
Launcher syntax What I need to do the following functions:
& lt; Input type = "article" id = "value1" /> & Lt; Input type = "text" id = "value2" /> & Lt; Input type = "text" id = "value3" /> & Lt; Input type = "text" id = "total" /> I want to display [[value1 * value2] + value3] and it results in two decimal places (forced, hence also if the result is an integer integer, should attach it) .00 ") and displayed in total < P>
"Post-text" itemprop = "text">
$ (function () {var roundDecimals = 2; var pow = Math.pow (10, roundDecimals); $ ('input [id ^ = value] '). Key (function () {var value1 = parseFloat ($ (' # value1 '). Val ()); Vari Value2 = parseFloat ($ (' # value2 '). Val ()); v Ar value3 = parseFloat ($ ('# value3'). Val (); if (INN (value1) || isNa (value2) || isNaN (Value3)) {return}} var total = value1 * value2 + value3 ; Total = Math.round (Total * Pau) / Pow; $ ('# Total'). Val (total.toFixed (roundDecimals))}};});
Comments
Post a Comment