문제

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;"> 
도움이 되었습니까?

해결책

Have you tried something like:

total = total * 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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top