'how to add percentage in total Amount using Jquery or Javascript
I have a need which calculates the percentage of amount , how to add Total+percentage and then display in Total. like Total 100 and ADD 10% then Total Show 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;">
Solution 1:[1]
Jquery
var Total = $("#TOTAL");
Total.val(Total.val() * 1.1);
JavaScript
var Total = document.getElementById("TOTAL");
Total.value *= 1.1;
Edit: For different percentages
var percent = 12.5;
var factor = 1 + percent/100;
Add this before and replace 1.1 with factor, like this
Total.value *= factor;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
