[jQuery] autocomplete and updating different fields from delimited string

[jQuery] autocomplete and updating different fields from delimited string


Hi all,
I'm using rhe great jquery autocomplete plugin which works great. But
Im returning a pipe delimited list so I can return more data and then
populate specific fields with that info. So for example my
autocomplete would return pipe delimited data like so for each line.
Top Gun|0001|11/22/06|10/31/06
Top Act|0002|11/22/06|10/31/06
In the display results of the autocomplete I wouldnt want to display
the full line just the first value of the pipe delimited string. So it
would display:
Top Gun
Top Act.
And if I selected Top Act it would update:
#title_name with the value 'Top Act'
the field #item with the value '0002',
the field #date1 with value '11/22/06'
the field #date2 with value '10/31/06'
Im a bit confused as to how to go about initiating a function to parse
the pipe delimited data to update the fields the way I want.
$(document).ready(function(){
$("#title_name").autocomplete("autosearch.html", {
width: 350,
    max: 50,
    cacheLength: 0,
    scroll: true,
    minChars: 4,
    minChars: 4,
autoFill: false,
        mustMatch: false,
        matchContains: false,
    selectFirst: false,
    extraParams: { d: function(){return $
("input[@name=radCateg]:checked").val();}}
});
$("#title_name").result(function(event, data, formatted) {
    if (data)
        $("#title_name").val(data[1]);
        $("#item").val(data[2]);
        $("#date1").val(data[3]);
        $("#date2").val(data[3]);
});
});