Avatar of Whing Dela Cruz
Whing Dela Cruz
Flag 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

ASP.NETHTMLJavaScript

Avatar of undefined
Last Comment
Whing Dela Cruz

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Banshi lal dangi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Whing Dela Cruz

ASKER
Thank you Banshi, Its working!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck