当前位置: 代码迷 >> Ajax >> ajax + jquery 兑现自动完成autocomplete
  详细解决方案

ajax + jquery 兑现自动完成autocomplete

热度:240   发布时间:2012-11-20 09:55:43.0
ajax + jquery 实现自动完成autocomplete
Code:
  1. <script???src= "${pageContext.request.contextPath}/js/jquery-1.5.1.js" >??
  2. </script>??
  3. ????????<script?type="text/javascript" ??
  4. ????????????src="${pageContext.request.contextPath}/js/jquery-ui-1.8.13.custom.min.js" >??
  5. </script>??
  6. ????????<link?rel="stylesheet" ?type= "text/css" ??
  7. ????????????href="${pageContext.request.contextPath}/css/jquery-ui-1.8.13.custom.css" ?/>??

代码实现

Code:
  1. <script?type= "text/javascript" >??
  2. var ?nameDate?=? "" ;??
  3. function ?onLoadMsg()?{??
  4. ???$("#cusName" ).autocomplete(?{??
  5. ????????autoFill?:?false ,??
  6. ????????matchContains:?true ,??
  7. ????????source?:?nameDate??
  8. ????});??
  9. ????var ?cusName?=?$( "#cusName" ).val();??
  10. ????jQuery.post("customer_nameSelect?cusName=" ?+?cusName,? function (data)?{??
  11. ????????nameDate?=?data;??
  12. ????});??
  13. ??????
  14. ??????
  15. }??
  16. function ?onShow(){??
  17. }??
  18. $().ready(function ()?{??
  19. });??
  20. </script>??

页面文件触发

Code:
  1. <input?type= "text" ?id= "cusName" ?name= "entity.customners.id" ??
  2. ????????????????????????????????????????onkeypress="onLoadMsg()" ?onkeyup= "onShow()" >??

效果图

  相关解决方案