Tuesday, September 29, 2009

[jQuery] autocomplete

Hi

My php is returning via json:

a string (name) which is displayed in the text box
an int (location_id)

When the form is posted I would also like to post 'location_id' as
well as / instead of 'name'.

My js is below. what do I need to do to be able to post the
location_id.

$("#quick-search").autocomplete('/includes/search.php', {
width: 300,
scroll: false,
dataType: "json",
parse: function(data) {
return $.map(data, function(row) {
return {
data: row,
value: row.location_id,
result: row.name
}
});
},
formatItem: function(mail) {
return mail.name;
}
});


Thanks

Asa

No comments: