Forums

Calculate Fields

rafaelscouto 12 Jul, 2019
I make the calculation of these fields (Ingresso * Publico).


function calcular() {
var n1 = parseFloat(document.getElementById('valor_do_ingresso').value);
var n2 = parseInt(document.getElementById('publico_aproximado').value);
document.getElementById('renda_ingressos').innerHTML = n1 * n2;
}

I'm using onkeyup: calcular() within the extra attributes field in the Ingresso and Publico fields.

The field (Renda) should receive the result of the calculation of the (Ingresso and Publico).

As can be seen in the image, typing the values shows the result of the value, but this result is not shown inside the field, what could have happened?


healyhatman 13 Jul, 2019
Answer
Because you're setting the innerHTML of the field, instead of the value.
This topic is locked and no more replies can be posted.