Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Calculating percentage

Hi experts, what is the best solution to get percentage profit between the capital cost and selling price? My code below is not consistent where if the amount will have a comma or like 1,000.00 it will no longer work.  

function CalculateProfit()
	var sp = document.getElementById("A5").value;
	var uc = document.getElementById("A3").value;
	var prt = (sp /(.01 * uc) - 100);
	//var n = prt.toFixed(2);
	var n = prt.toFixed(0);
	document.getElementById("A4").value = n + "%"; 


Open in new window

Avatar of Banshi lal dangi
Banshi lal dangi
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz


Thank you Banshi, Its working!