0
I have a simple javascript function that calculates the value of one field multiplied by the value of another and inserts it into a third. Below the code:
function multiplica() {
var quantidade = parseFloat(document.getElementById("tab1quantidade").value);
var aux = document.getElementById("tab1valor");
var valor = parseFloat(aux.options[aux.selectedIndex].value);
document.getElementById("tab1total").value = parseFloat(quantidade * valor).toFixed(2);
}
The fields are as follows:
<td class="col-md-3">
<input type="number" min="0" max="10" step="1" class="form-control text-center" name="bulletin['tab6quantidade']" id="tab6quantidade" value="0" onChange="multiplica();">
</td>
I need to use this same function for other fields but with different Ids. I have to pass the field ID as parameter but do not know how to enter the data correctly.
Shows more HTML and the relationships between the accounts you want to do.
– Sergio