Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Jquery或Javascript在总额中添加百分比_Javascript_Jquery_Percentage - Fatal编程技术网

如何使用Jquery或Javascript在总额中添加百分比

如何使用Jquery或Javascript在总额中添加百分比,javascript,jquery,percentage,Javascript,Jquery,Percentage,我需要计算金额的百分比,如何添加总计+百分比,然后显示总计。如总数为100,加上10%,则总数为110 HTML Code <input type="text" name="TAXES" id="TAXES"style="width:100px;" > <input type="text" name="TOTAL" value="100" id="TOTAL" style="width:100px;"> HTML代码 您是否尝试过以下方法: total

我需要计算金额的百分比,如何添加总计+百分比,然后显示总计。如总数为100,加上10%,则总数为110

 HTML Code

  <input type="text" name="TAXES"  id="TAXES"style="width:100px;" >

  <input type="text" name="TOTAL" value="100" id="TOTAL" style="width:100px;"> 
HTML代码

您是否尝试过以下方法:

total = total * 1.1
Jquery

JavaScript

var Total = document.getElementById("TOTAL");
Total.value *= 1.1;
编辑:用于不同的百分比

var percent = 12.5;
var factor = 1 + percent/100;
在前面添加此项,并用因子替换1.1,如下所示

Total.value *= factor;

你尝试了什么,你被困在哪里了。这些都是你需要添加到这个问题上的东西。那么,到目前为止,你尝试/研究了什么…?如果我总共添加了12.5%,那么我是什么doing@EvanKnowles你能告诉我为什么你把它乘以1.1,而在问题中,用户说10%,我认为是。1@usama如果我们把它乘以0.1,我们会得到原始数字的10%,而不是原始数字加上另外10%(100%+10%==110%,等于1.1)
Total.value *= factor;