实现txtbox的AutoComplete
来源:互联网 发布:mac 装win10 编辑:程序博客网 时间:2024/05/20 11:21
实现效果
前台代码
<script language="javascript" type="text/javascript"> function BxdwResult() { var BxdwTxt = document.getElementById("txtBxdw"); if (BxdwTxt.value != null && BxdwTxt.value != "") { Otitan.Web.ForestCuttingManage.CuttingQuota.QuotaManage.QuotaQuery.QuatoQueryManage.GetCompilationUnitList(BxdwTxt.value, get_Bxdw_Result_CallBack); } else { document.getElementById("ddlTxtBox").style.display = "none"; var unitcode = document.getElementById("unitcode"); unitcode.value = ""; } } function get_Bxdw_Result_CallBack(response) { var unitcode = document.getElementById("unitcode"); unitcode.value = ""; if (response.value != null) { //debugger; document.getElementById("ddlTxtBox").style.display = "block"; document.getElementById("ddlTxtBox").length = 0; var ds = response.value; if (ds != null && typeof (ds) == "object" && ds.Tables != null) { for (var i = 0; i < ds.Tables[0].Rows.length; i++) { var name = ds.Tables[0].Rows[i].UNITNAME; var id = ds.Tables[0].Rows[i].UNITCODE; document.getElementById("ddlTxtBox").options.add(new Option(name, id)); } } } else { document.getElementById("ddlTxtBox").style.display = "none"; } return } function getData() { var province = document.getElementById("ddlTxtBox"); var bxdw = document.getElementById("txtBxdw"); var pindex = province.selectedIndex; var unitcode = document.getElementById("unitcode"); unitcode.value = ""; // var pname = province.selectedValue; if (pindex != -1) { var pValue = province.options[pindex].value; //var pUnit = province.options[pname].value; unitcode.value = pValue; bxdw.value = province.options[pindex].text; province.style.display = "none"; //window.location.href = "PreDeclarationed.aspx?xmid=" + pValue; } else { province.style.play = "none"; } } </script>
<asp:TextBox ID="txtBxdw" runat="server" Width="90%" CssClass="TextBox_XBSJ_1"></asp:TextBox> <input name="unitcode" type="hidden" id="unitcode" runat="server" /> <div style=" position:relative; "> <div style=" position: absolute;width:105%; left:-5%;"> <table style="margin-top: 0px; padding-top: 0px; width:90%"> <asp:ListBox ID="ddlTxtBox" runat="server" Style="display: none" Width="100%"> </asp:ListBox> </table> </div> </div>
后台代码
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)] public DataSet GetCompilationUnitList(string value) { string where = "select * from view_compilationunit t where t.unitname like '%" + value + "%'"; DataSet ds = DbHelperOra.Query(where); return ds; }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(QuatoQueryManage)); if (!IsPostBack) { this.txtBxdw.Attributes.Add("onkeyup", "BxdwResult();"); this.ddlTxtBox.Attributes.Add("onclick", "getData();"); } }
扩展阅读
1、使用AutoCompleteExtender控件 http://www.cnblogs.com/SilverLight/archive/2008/09/28/1301755.html
2、AutoCompleteExtender返回text-value键值对的变通方法
http://blog.csdn.net/ytc_1224/article/details/4040801
- 实现txtbox的AutoComplete
- autocomplete+PHP+MYSQL的实现模糊查询
- autocomplete+PHP+MYSQL的实现模糊查询
- AutoComplete实现关键字提示
- dojo实现autocomplete
- jQuery AutoComplete实现
- Django & JQuery 实现 Autocomplete
- Django & JQuery 实现 Autocomplete
- 实现autocomplete技术
- jquery实现的自动关联的Autocomplete插件
- 使用jquery的autocomplete实现类似百度的输入提示
- suggestTree-实现rank-ordered autocomplete suggestions的数据结构
- Solr的自动完成/自动补充实现介绍(1): autoComplete
- Solr的自动完成/自动补充实现介绍(2):autoComplete
- suggestTree-实现rank-ordered autocomplete suggestions的数据结构
- suggestTree-实现rank-ordered autocomplete suggestions的数据结构
- Ext的comboBox结合Servlet、JSON实现AutoComplete
- 使用jquery autocomplete实现类似搜索引擎的自动填充功能
- CSS3 Media Queries 响应式网页设计
- C++堆、栈、自由存储区、全局/静态存储区和常量存储区 .
- rman backup命令创建备份之保护备份
- Unity GUIskin开发包(超炫)
- Android 在Eclipse 下查看android API 以及Source 包
- 实现txtbox的AutoComplete
- bochs `` 12.04
- win7/win8安装sql server2005教程并启动服务
- 码农
- mysql替换字段中的回车换行符
- 广泛收集的jQuery拖放插件
- 高斯混合模型学习笔记
- lanmp一键安装包随堂笔记
- 三维坐标点绕任意轴旋转的新坐标计算