With the help of @luccascosta I was able to run a code in which, when clicking on a checkbox, it captures the value of that checkbox and updates the value in another input. The problem now is that by clicking on this checkbox, I need to update multiple inputs at the same time. I even managed to do the calculations, but now I can not play the result on their respective inputs.
Note the code:
var evento = document.querySelectorAll('input[type="checkbox"]');
for (let i = 0; i < evento.length; i++) {
evento[i].addEventListener('click', AddValor);
}
function AddValor() {
var val_evento = parseFloat(this.value, 10);
var pacote = new Array();
$('.valor_principal').each(function() {
pacote.push($(this).val());
});
for (let i = 0; i < pacote.length; i++) {
var total = jQuery.parseJSON(pacote[i]);
this.checked == true ? total += val_evento : total -= val_evento;
alert(total);
pacote[i].value = total;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="checkbox" id="evento_value1" value="99.00">
<input type="checkbox" id="evento_value2" value="120.00">
<input type="checkbox" id="evento_value3" value="99.00">
<input type="checkbox" id="evento_value4" value="300.00">
<input type="checkbox" id="evento_value5" value="5.00">
<input class="valor_principal" value="100">
<input class="valor_principal" value="200">
<input class="valor_principal" value="300">
In the alert (total) you can observe the result happening ...
Aogra, I need him to update the values in each
Thanks for the help ...