for(a=1; a<=2; a++){
$("#inp-"+a+" .nama").autocomplete({
source: function( request, response ) {
$.ajax({
url: "states_remote.php",
dataType: "json",
data: {term: request.term},
success: function(data) {
response($.map(data, function(item) {
return {
value: item.nama,
pangkat: item.pangkat,
jabatan: item.jabatan,
nip: item.nip
};
}));
}
});
},
minLength: 2,
select: function(event, ui) {
$("#inp-"+a+" .pangkat").val(ui.item.pangkat);
$("#inp-"+a+" .nip").val(ui.item.nip);
$("#inp-"+a+" .jabatan").val(ui.item.jabatan);
$(this).next('.nama').focus();
},
html: true,
open: function(event, ui) {
$(".ui-autocomplete").css("z-index", 1000);
}
});
}
i want use loop variable 'a' into autocomplate select function, but i cant get access to call variable in this function
select: function(event, ui) {
$("#inp-"+a+" .pangkat").val(ui.item.pangkat);
$("#inp-"+a+" .nip").val(ui.item.nip);
$("#inp-"+a+" .jabatan").val(ui.item.jabatan);
$(this).next('.nama').focus();
},
can someone help me to solved my problem? i search in other topic maybe this name is asynchronous function.
Aucun commentaire:
Enregistrer un commentaire