Use of AutoComplete

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.