troubleshooting Question

Calculating percentage

Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla asked on
ASP.NETHTMLJavaScript
2 Comments1 Solution162 ViewsLast Modified:
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 + "%"; 

}
ASKER CERTIFIED SOLUTION
Banshi lal dangi
Full Stack Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros