I'm trying to dynamically sum the values of some inputs generated with jQuery based on the number set on other input, but cant make them properly sum,I'll be searching a bit more for another way since .each
and .click
won't work and .on('click'
seems to just add the numbers to the variable but if any number is lowered it'll just add it again, if anyone can come with any creative idea, it would be a lot of help
$( document ).ready(function() {
var existimos = 0;
$('#sacos').change(function() {
var cantidad = $('#sacos').val();
var inputeador = '<div class="yosoy">';
function imprimesacos(){
if(cantidad > existimos) {
inputeador += '<input id="yosoy' + existimos + '" name="yosoy' + existimos + '" />';
existimos++;
imprimesacos();
};
};
imprimesacos();
inputeador += '</div>';
$('#imprimidor').html(inputeador);
});
});