代码计算1% [英] Code to calculate 1%

查看:88
本文介绍了代码计算1%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个简单的任务,但对我的网站上的java或编码知之甚少我有一个我想要的在线支付表格作为支付金额的字段,加上1%作为附加费通知客户,当他们接受时,然后用新金额更新原始字段,有人可以帮我提供这个代码吗?

Hi All,

I have a simple task but don't know enough about java or coding on my website I have an online payment form I want to take the field that is the amount to be paid and add 1% as a surcharge advise the customer and when they accept it then updates the original field with the new amount, Can someone help me with the code of this?

推荐答案

我不确定java语法,但你可以试试这样的东西。它简单的数学问题

i am not sure about java syntax but you can try something like this. its simple maths problem
var newamount = oldamount(origional amount) * 1(this is your percentage)/100;



您需要带关心小数点精度或有时从字符串到十进制的转换可能是。



希望这会有所帮助。







更正格式问题。

添加标签。

[/编辑]


您好,



试试这个JavaScript



Hi,

Try this JavaScript

<script type="text/ecmascript">
        function calculate()
        {
            var onePerc = amount * (percentage/ 100);
            alert(onePerc);
        }
    </script>





GoodLuck



GoodLuck


这篇关于代码计算1%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆