JQuery Autocomplete - format listing and only return a part to the text box

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-04-27T14:11:02Z Indexed on 2010/04/27 14:13 UTC
Read the original article Hit count: 519

Filed under:
|

I'm using the JQuery Autocomplete and it's working just fine. I'm using it to allow someone to search for users out of a database by searching on last name or id number.

Right now the drop down list that is created is the resultes of a SQL query and looks something like:

$row_rst['lName'] . ', ' . $row_rst['fName'] . " - " . $row_rst['user'] . "|" . $row_rst['id']

which outputs something like:

Jones, Henry - hjones
Gibbons, Peter - pgibbons

When I pick Henry the text box gets Jones, Henry - hjones and the hidden field gets his id.

I'd like to format the drop down in columns if possible and only return Jones, Henry to the text box if possible.

Are either of those options possible? I'm thinking it has to do with either formatItem(row) or formatResult(row) but I'm not sure and I can't seem to find how to go about this.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about autocomplete