i have this code to populate the option in my select box(i have 7 select box in this page) with json response from the server(ajax)
for (j=1; j <= 7; j++){
$.getJSON('mobile_json.php', {id:j}, function(data) {
var select = $('#userAccess' + j);
var options = select.attr('options');
$.each(data, function(index, array) {
options[array['Id']] = new Option(array['Name']);
});
});
}
The problem is after the calling to the ajax, the j
equal to 8
,
what i want is when the function deal with the json array, is set it to the right select box like : userAccess1 , userAccess2 ... userAccess7,
how can i deal with it.
thanks