-1

我正在使用其他人的有效代码。我只需要它四舍五入到小数点后第二位。它的作用是当您输入数字时,它将它添加或减去它到页面上的另一个字段

<cfset TextJS = TextJS & "var $EH_LEFH#CurrentRow# = $('##EH_LEFH#CurrentRow#');var $MH_LEFH#CurrentRow# = $('##MH_LEFH#CurrentRow#');$EH_LEFH#CurrentRow#.keyup(function () {$MH_LEFH#CurrentRow#.val(parseFloat($(this).val()) - #getLast.LTSN#);});">
<cfset TextJS = TextJS & "var $EH_LCYCLES#CurrentRow# = $('##EH_LCYCLES#CurrentRow#');var $MH_LCYCLES#CurrentRow# = $('##MH_LCYCLES#CurrentRow#');$EH_LCYCLES#CurrentRow#.keyup(function () {$MH_LCYCLES#CurrentRow#.val(parseFloat($(this).val()) - #getLast.LCSN#);});">
<cfset TextJS = TextJS & "var $EH_REFH#CurrentRow# = $('##EH_REFH#CurrentRow#');var $MH_REFH#CurrentRow# = $('##MH_REFH#CurrentRow#');$EH_REFH#CurrentRow#.keyup(function () {$MH_REFH#CurrentRow#.val(parseFloat($(this).val()) - #getLast.RTSN#);});">
<cfset TextJS = TextJS & "var $EH_RCYCLES#CurrentRow# = $('##EH_RCYCLES#CurrentRow#');var $MH_RCYCLES#CurrentRow# = $('##MH_RCYCLES#CurrentRow#');$EH_RCYCLES#CurrentRow#.keyup(function () {$MH_RCYCLES#CurrentRow#.val(parseFloat($(this).val()) - #getLast.RCSN#);});">
<cfset TextJS = TextJS & "$MH_LEFH#CurrentRow#.keyup(function () {$EH_LEFH#CurrentRow#.val(parseFloat($(this).val()) + #getLast.LTSN#);});">
<cfset TextJS = TextJS & "$MH_LCYCLES#CurrentRow#.keyup(function () {$EH_LCYCLES#CurrentRow#.val(parseFloat($(this).val()) + #getLast.LCSN#);});">
<cfset TextJS = TextJS & "$MH_REFH#CurrentRow#.keyup(function () {$EH_REFH#CurrentRow#.val(parseFloat($(this).val()) + #getLast.RTSN#);});">
<cfset TextJS = TextJS & "$MH_RCYCLES#CurrentRow#.keyup(function () {$EH_RCYCLES#CurrentRow#.val(parseFloat($(this).val()) + #getLast.RCSN#);});">
4

1 回答 1

2

只需使用.toFixed

详细文档在这里: https ://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed

[编辑] 我的新猜测:

<cfset TextJS = TextJS & "$MH_LCYCLES#CurrentRow#.keyup(function () {$EH_LCYCLES#CurrentRow#.val((parseFloat($(this).val()) + #getLast.LCSN#).toFixed(2));});">
于 2012-11-07T20:59:29.983 回答