I have the following for
where I try to fill a dynamic input text, the question is that I do not know how to assign the path value of for
to be able to fill them correctly:
for (var j = 0; j < respuesta.length; j++) {
//console.log("indice", i);
$("caja" + j + ).val(bolsas2[j]); //Obviamente no funciona, necesito asignar en el input text id=caja"x" el valor "x"
}
Thank you very much for the help.
EDITED
I create the inputs with the first for, with the second the full ones
$(".box-body").html("");
for (var k = 0; k < numCa; k++) {
console.log("indice", k);
$(".box-body").append('<div class="form-group linea"><div class="input-group"><span class="input-group-addon"><i class="fa fa-user"></i></span><input type="text" class="form-control input-lg" id="caja ' + +'" name="caja ' + k + '" value="123" required></div></div>');
}
for (var j = 0; j < respuesta.length; j++) {
//console.log("indice", i);
//$("#caja " + j).val(bolsas2[j]);
console.log($("#caja " + j).val());
console.log("Bolsas: ", bolsas2[j]);
console.log($("#cajas " + j).find('input[type="text"].form-control').attr('id'));
}
I can not see the console value of "123" using this line console.log($("#caja " + j).val());
, I feel it is not the correct way to catch the element