html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AuCom.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="Js/jquery.autocomplete.css">
<link rel="stylesheet" href="css/style.css" type="text/css"></link>
<script type="text/javascript" src="Js/jquery-1.4.1.js"></script>
<script type="text/javascript" src="Js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="Js/acom.js"></script>
</head>
<body>
<input type="text" id="aa"/>
<!-- <span id="bb"></span>-->
</body>
</html>
js:
$(document).ready(function() {
$("#aa").autocomplete("/MyJs/MyTestServlet",{
max:4,
// delay: 400,
dataType:"json",
// extraParams:{"dept_id":1},//传过去的固定值
parse:function(data){
return maps=$.map(data[0].data,function(item,index){
return {
data:item,
value:item["id"]+"",
// value:item["id"]+"", //数字+""
result:function(){
return item["id"];
}
};
});
},
formatItem:function(row,index,len){//这里的row相当于data
// alert(row.tname);
return row.tname;
},
formatResult:function(v){
$("#aa").submit_id=v["id"];
return v.id;
}
});
});