0
I would like this code to take the cents of the value coming from the javascript variable
preco = parseInt(preco);
I’ve put nothing like that
preco = parseFloat(preco);
Complete code below
total = 0;
function adiciona(id) {
    calcula(id, "adicao");
}
function remove(id) {
    calcula(id, "subtracao");
}
function calcula(id, operacao) {
    nomeid = "nome" + id;
    precoid = "preco" + id;
    qtdid = "qtd" + id;
    nome = document.getElementById(nomeid).innerHTML;
    preco = document.getElementById(precoid).innerHTML;
    preco = parseInt(preco);
    qtd = document.getElementById(qtdid).innerHTML;
    qtd = parseInt(qtd);
    //Debug
    //alert("Produto: " + nome + "\n Preço: " + preco);    
    if (operacao == "adicao") {
        total = total + preco;
        qtd = qtd + 1;
    } else {
        total = total - preco;
        qtd = qtd - 1;
    }
    document.getElementById(qtdid).innerHTML = qtd;
    document.getElementById("total").innerHTML = total;
}
What gives
alert(document.getElementById(precoid).innerHTML);? and you just want to get the decimal part, that’s it?– Sergio
for example the value this 60,80 only appears 60 understood
– Hemerson Prestes