1
I have a function in a part of the system that is not working. Error appears Uncaught TypeError: addPriceAddProd.replace is not a function
but I don’t know what I’m doing wrong. Could anyone help me? Follow my code that does the action.
function subtrairMenos1Add<?=$idIngredientAdicional?>() {
var n1 = parseInt(document.getElementById('qtdIngredientAdicional<?=$idIngredientAdicional?>').value);
var n2 = parseInt(1);
document.getElementById('qtdIngredientAdicional<?=$idIngredientAdicional?>').value = n1 - 1;
valorInputGeneral = document.getElementById('qtdIngredientAdicional<?=$idIngredientAdicional?>').value;
orgPriceProd = document.getElementById("orgPriceProd").value;
if(valorInputGeneral < 1) {
document.getElementById('qtdIngredientAdicional<?=$idIngredientAdicional?>').value = 0;
}
if(valorInputGeneral > 0){
//if(valorInputGeneral > 0){
var priceAdicional = document.getElementById("adicionalPrice<?=$idIngredientAdicional?>").value;
//alert(priceAdicional);
var priceProd = document.getElementById("priceProd").value;
var priceProdFormatAm = priceProd.replace(",",".");
var addPriceAddProd = parseFloat(priceProdFormatAm) - parseFloat(priceAdicional);
//alert(addPriceAddProd);
//var priceProdFormatBr = addPriceAddProd.replace(".",",");
var addPriceAddProdBr = addPriceAddProd.replace(".",",");
alert(addPriceAddProdBr);
document.getElementById("priceProd").value = addPriceAddProd;
//}
}
if(valorInputGeneral <= 0){
document.getElementById("priceProd").value = orgPriceProd;
}
}
Thank you very much!! solved my problem
– William De Paula