[jQuery] autocomplete

[jQuery] autocomplete

I'm trying to use autocomplete on a dialog windows that has a editing
form for the user to change data previously saved so every
autocomplete input has data that can be change. The problem is when i
do change a value and try to update an input with part of the data
returned by the autocomplete script.
This is what i am doing but is not working
$.ajax({
type: "POST",
url: "contabilidad/totalAsientos.php",
data: "idasiento="+id,
success: function(respuesta){
var totallineas = parseInt
(respuesta);
for(var j=0; j<totallineas; j++){
$
("#codigocuenta"+j).autocomplete("contabilidad/
autocompleteasiento.php" ,{
minChars: 1,
width: 400,
max: 20,
autoFill:
true
}).result(function(event,
data, formatted) {
if (data!=""){
$
("#codigocuenta"+j).val(data[1]);
$
("#denominacion"+j).val(data[2]);
}
});
} //endfor
}
})
Is there a way to do what a want to do?