I want to do something very simple, but simple as it is, I can not. I have an input that receives the cost value, an input that calculates and shows the profit margin in% and an input that receives the sales price.
Thequestionisasfollows,thewayIgotittoday,thecalculationisdonecorrectlyonlyuptothevalue($999.99),whenitreachesthethousands,thecalculationofawrongvalue,forexample:
Andaboveall,thecalculationignoresthedecimalplaces.IfIputasalepricebeing$199.00ofthesameprofitmarginasIput$199.99,thatis,199.90heseesas199and199.00healsoseesas199.ItseemstobesomethingsosimpleandIcannotdoit.
CodeIcurrentlyhave:
varprecoVenda=parseFloat($("input[name='iptPrcVendaProdutoEditar']").val());
var precoCusto = parseFloat($("input[name='iptPrcCustoProdutoEditar']").val());
var margemLucro = parseFloat((((precoVenda - precoCusto)/precoCusto)*100)).toFixed(2);
$("input[name='iptMargemLucroProdutoEditar']").val(margemLucro.replace('.',','));