AutoComplete uses a method that divides the local call method and reads the remote read data source
(1) Local Call method
<script src= "Scripts/jquery-1.4.1.min.js" type= "Text/javascript" ></script>
<link href= "Scripts/jquery.autocomplete.css" rel= "stylesheet" type= "Text/css"/>
<script src= "Scripts/jquery.autocomplete.min.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
var emails = [
{name: "Peter Pan", to: "[email protected]"},
{Name: "Molly", To: "[email protected]"},
{name: "Forneria Marconi", to: "[email protected]"},
{name: "Master <em>Sync</em>" to: "[email protected]"},
{name: "Dr <strong>Tech</strong> de Log", To: "[email protected]"},
{name: "Don Corleone", To: "[email protected]"},
{name: "Mc Chick", to: "[email protected]"},
{name: "Donnie Darko", to: "[email protected]"},
{Name: "Quake the Net", to: "[email protected]"},
{Name: "Dr. Write", to: "[email protected]"},
{name: "GG Bond", to: "[email protected]"},
{name: "ZhuZhu Xia", to: "[email protected]"}];
$ (function ()
{
$ (' #txt '). AutoComplete (Emails, {
Number of entries in Max:12,//List
Minchars:1,//The minimum character that is filled in automatically before activation, and if 0, displays all when double-clicked
width:400,//width of hint, overflow hidden
scrollheight:300,//height of cue, overflow display scroll bar
Matchcontains:true,//contains a match, is the data parameter, whether the data contained in the text box is displayed
Autofill:false,//auto-fill
Formatitem:function (row, I, max)
{
return row.name;
},
Formatmatch:function (row, I, max)
{
return row.name;
},
Formatresult:function (Row)
{
return row.name;
}
});
});
</script>
<input type= "text" id= "txt"/>
(2) Ways to remotely invoke a data source
Backstage. js
viewstate["Data"]= "[{name: \" Peter pan\ "},{name: \" molly\ "},{name: \" Forneria marconi\ "},{name: \" Don corleone\ "}]";
Front desk
<script src= "Scripts/jquery-1.4.1.min.js" type= "Text/javascript" ></script>
<link href= "Scripts/jquery.autocomplete.css" rel= "stylesheet" type= "Text/css"/>
<script src= "Scripts/jquery.autocomplete.min.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function ()
{
var data = ' <%= viewstate[' data '%> ';
var da = eval (' (' + data + ') ');
$ (' #txt '). AutoComplete (DA, {
Number of entries in Max:12,//List
Minchars:1,//The minimum character that is filled in automatically before activation, and if 0, displays all when double-clicked
width:400,//width of hint, overflow hidden
scrollheight:300,//height of cue, overflow display scroll bar
Matchcontains:true,//contains a match, is the data parameter, whether the data contained in the text box is displayed
Autofill:false,//auto-fill
Formatitem:function (row, I, max)
{
return row.name;
},
Formatmatch:function (row, I, max)
{
return row.name;
},
Formatresult:function (Row)
{
return row.name;
}
});
});
</script>
<input type= "text" id= "txt"/>
Use of AutoComplete