下拉框自动完成(autocomplete)带有分页功能SutaraLumpur-jquery.ajaxComboBox.js的使用
2014-02-19 15:10 -夜 阅读(931) 评论(0) 编辑 收藏 举报效果图:
SutaraLumpur-jquery.ajaxComboBox.js简介地址:http://d.hatena.ne.jp/sutara_lumpur/20090124/1232781879
下载地址:https://github.com/SutaraLumpur/jquery.ajaxComboBox.js/zipball/master
html代码:
<input type="text" name="txtZdType" id="txtZdType" autocomplete="off" />javascript代码:
<script src="../Scripts/jquery-1.8.3.min.js" type="text/javascript"></script> <link href="../Scripts/acbox/jquery.ajaxComboBox.css" rel="stylesheet" type="text/css" /> <script src="../Scripts/acbox/jquery.ajaxComboBox.7.1.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { //选择入院诊断Ajax自动完成 $('#txtZdType').ajaxComboBox("/WebService/AjaxService.asmx/GetBaicd", { lang: 'en', per_page: 15, field: 'Name', list_field: 'py' }); }); </script>C# WebService代码:
/// <summary> /// 根据传人的参数,分页的诊断数据 /// </summary> /// <param name="page_num">当前页码</param> /// <param name="per_page">每页显示条数</param> [WebMethod] public void GetBaicd(int page_num, int per_page) { //string and_or, string db_table, string[][] order_by, string[][] desc, string[] search_field; HttpRequest Request = HttpContext.Current.Request; string q_word = Request["q_word[]"]; ba_icd10BLL bll = new ba_icd10BLL(); int count = bll.GetCount();//总条数 StringBuilder sb = new StringBuilder(); sb.Append("{\"result\":"); string strWhere = ""; if (!string.IsNullOrWhiteSpace(q_word)) { strWhere = string.Format("where Py like '{0}%' or Name like '{0}%'", q_word); } List<ba_icd10Info> lst = bll.GetPagerList(page_num, per_page, strWhere); if (lst != null && lst.Count > 0) { JavaScriptSerializer jss = new JavaScriptSerializer(); jss.Serialize(lst, sb); } sb.AppendFormat(",\"cnt_whole\":{0}}}", count); //return sb.ToString(); HttpContext.Current.Response.Write(sb.ToString()); HttpContext.Current.Response.End(); }
ps:当前项目使用的时候,修改了网上下载的jquery.ajaxComboBox.7.1.js,
改动位置:69,87行,文件路径,1293 匹配正则,1302自动完成匹配字段,1827行赋值到其它文本框。
版权声明:本文为博主原创文章,未经博主允许不得转载。