Calculate Fields

calculate a field value in ChronoForms.

Overview

The calculation result is not appearing inside the target field because the script incorrectly updates the field's innerHTML property.
Update the script to set the 'value' property of the target field instead of the 'innerHTML' property.

Answered
Connectivity v6
ra 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?


Calculate Fields image 1
he 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.