代码改变世界

autocomplete 之 ASP.NET

2014-09-03 23:21  Bryran  阅读(204)  评论(0编辑  收藏  举报

 

<link href="CSS/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="JS/jquery.js" type="text/javascript"></script>
<script src="JS/jquery.autocomplete.js" type="text/javascript"></script>

 

 <script type="text/javascript">
        $().ready(function() {

            function findValue(li) {
                if (li == null) { return alert("No match!"); }
                if (!!li.extra)
                    var sValue = unescape(li.extra[0]);
            }
            function selectItem(li) {
                findValue(li);
            }

            $("#autoCompeteleTxt").autocomplete("Handler1.ashx", {
                delay: 10,
                minChars: 1,
                matchSubset: 1,
                cacheLength: 1,
                onItemSelect: selectItem,
                onFindValue: findValue,
                autoFill: true,
                maxItemsToShow: 20
            });
        });
    </script>

 

body:

 <input type="text" value="" id="autoCompeteleTxt" />

 

效果图:

 

 

 

源码:Demo