problem with autocomplete plugin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

problem with autocomplete plugin

Relez

Hi list, I need some help with autocomplete plugin.

I have two text field (name and surname) and I need to add to the name
field the autocomplete like this:
When the user start writing on it, it shows the coincidences and when
he select the correct item the surname field most be filled too. For
example:

HTML tags:

<input type="text" id="name" /><br />
<input type="text" id="surname" /><br />

Javascript code:

$().ready(function() {
        $("#name").autocomplete(records, {
                minChars: 0,
                width: 250,
                matchContains: 1,
                autoFill: true,
                onItemSelect: function(row) {
                        $("#surname").value = row.surname;
                },
                onFindValue: function(row) {
                        $("#surname").value = row.surname;
                },
                formatItem: function(row, i, max) {
                        return row.name + " " + row.surname;
                },
                formatMatch: function(row, i, max) {
                        return row.name;
                },
                formatResult: function(row) {
                        return row.name;
                }
        });

});

*************************
records its a javascript array like:

var records = [
{ name: "John", surname: "Smith"},
{ name: "Ian", surname: "Crawford"},
{ name: "Derek", surname: "Lee"}
];

As I can see, I have problems with "onFindValue" and "onItemSelect"
events.

Thanks!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---