I need some help, I can't identify or the code doesn't recognize me the element i'm looking for, to add a value. I have an iterator that create multiple selects, and I have another select that gets filled after the first ones are created. So the problem is when I want to fill the second ones, they don't get filled, I don't know why. Here is the iterator code to create multiples select inside my code:
$.getJSON("/ajax/load_files.php",{req:id_req},function(data){
rows=data['id_art'].length;
for(i=0;i<rows;i++){
<select class="form-control agent'+i+'" id="sel_agent_'+i+'" disabled style="margin-top: 0px">
<option value="0">No available</option>
</select>
And here's my getJSON to receive the information to get filled after creating the select: (Obiously the getJSON works and returns me everything ok, but I can't set the second select with the received data from the getJSON:
$.getJSON("/ajax/search_agents.php",{id_prov:data["idprov"][i]},function(data5){
if(data5!==false){
total=data[0].length;
var div5="";
for(var c=0;c<total;c++){
div5 += '<option value="' + data5[0][c] + '">' + data5[1][c] + '</option>';
}
$("#sel_agent_"+i+"").html(div5);
}else{
$("#sel_agent_").val("Prov. not loaded");
}
});
I get this JSON as a result [["28"],["David Beckham"]] (it's not problem) I think that the problem it's in this line: $("#sel_agent_"+i+"").html(div5); Since it's not filling it correctly, I've just checked the select id and everything and it's correct.