最常用的表单相乘js保留2位小数

<script type="text/javascript">
function count(){
var a = parseFloat(document.getElementById("c-price").value);
var b = parseFloat(document.getElementById("c-number").value);
var c = a*b;
var d ;
d = c.toFixed(2);
document.getElementById("c-sumprice").value = d;
}
</script>

 

<div class="col-xs-12 col-sm-8">
<input id="c-sumprice" data-rule="required" class="form-control" step="0.001" name="row[sumprice]" type="number" value="{$row.sumprice|htmlentities}" onclick="count()">
</div>

posted @ 2019-12-25 15:35  阿波罗任先生  阅读(974)  评论(0编辑  收藏  举报