日期:2014-05-16 浏览次数:20601 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<script type="text/javascript" src="jquery.autocomplete.pack.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script language="javascript">
$(document).ready(function(){
            $("#payee_name").autocomplete(    
            "getindex.php",    
            {    
                delay:10,    
                minChars:1,    
                matchSubset:1,    
                matchContains:1,    
                cacheLength:10,    
                onItemSelect:selectItem,    
                onFindValue:findValue,    
                formatItem:formatItem,    
                autoFill:false    
            }    
            );    
               
            function findValue(li) {    
                if( li == null ) return alert("No match!");    
                if( !!li.extra ) var sValue = li.extra[0];    
                else var sValue = li.selectValue;  alert("1");  
                }    
            function selectItem(li) { findValue(li);alert("2"); }    
            function formatItem(row) {return row[0];//return row[0] + " (id: " + row[1] + ")"//如果有其他参数调用row[1],对应输出格式Sparta|896    
            }    
            function lookupAjax(){             
            var oSuggest = $("#payee_name")[0].autocompleter;    
            oSuggest.findValue();    
            return false;    
            }
            });
            </script>
<title>自动完成测试</title>
</head>
<body>
<input type="text" name="keyword" id="payee_name" size="30" />
<input type="text" name="keyword" id="payee_name2" size="30" />
<input type="text" name="keyword" id="payee_name3" size="30" />
</body>
</html>