View Full Version : jQuery: question about autocomplete and keys.

03-04-2011, 03:44 PM

I have a multiple select and an autocomplete input. Each time the user insert an element in the autocomplete input I would like to select the corresponding element in the multiple select.

I have this code:

.autocomplete('autocomplete', jQuery.extend({}, {
dataType: 'json',
parse: function(data) {

var parsed = [];
for (key in data) {

parsed[parsed.length] = { data: [ data[key], key ], value: data[key], result: data[key] };

return parsed;

}, {multiple:true}))
.result(function(event, data) {
$("#select option[value=" + key + "]").attr("selected", true);


The action autocomplete is returning this kind of data:


The problem: the value of "key" (value=" + key + ") is always 18, even when i select element_17.

Any idea what should i change/add?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum