Question

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;"> 
Was it helpful?

Solution

Have you tried something like:

total = total * 1.1

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top