The text box automatically matches the phone number and name, and the data is the JSON data that is found, which encapsulates all objects (telephone, cellphone, name). Select a phone number,
The code for automatically filling a name is as follows:
$. Ajax ({
URL: '/account/ajaxfinduserphonelist ',
Type
: 'Post ',
Cache: false,
Contenttype: "application/JSON ",
Datatype: "JSON ",
Success: function (data ){
$ ("# Input_pair_phone"). AutoComplete (data ,{
MAX: 50, // number of entries in the list
Minchars: 0, // minimum character entered before the activation is completed automatically
Width: 210,
Scrollheight: 1000, // The height of the prompt. the scroll bar is displayed if it overflows.
Matchcontains: True, // contains matching, that is, the data in the data parameter, whether the data in the package text box is displayed
AutoFill: false, // Auto Fill
Formatitem: function (row, I, max ){
If (row. Telephone! = NULL & Row. Telephone! = 'Null' & Row. Telephone! = ''){
Return row. Telephone + ''+ row. Name;
} Else if (row. cellphone! = NULL & Row. Telephone! = 'Null' & Row. cellphone! = ''){
Return row. Cellphone + ''+ row. Name;
}
},
Formatmatch: function (row, I, max ){
If (row. Telephone! = NULL & Row. Telephone! = 'Null' & Row. Telephone! = ''){
Return row. Telephone + ''+ row. Name;
} Else if (row. cellphone! = NULL & Row. Telephone! = 'Null' & Row. cellphone! = ''){
Return row. Cellphone + ''+ row. Name;
}
},
Formatresult: function (ROW ){
If (row. Telephone! = NULL ){
Return row. Telephone;
} Else if (row. cellphone! = NULL ){
Return row. Cellphone;
}
}
}). Result (function (event, row, formatted ){
If (row. Telephone! = NULL | row. cellphone! = NULL ){
$ ('# Input_pair_phone_name'). Val (row. Name );
}
});
}
});