【问题标题】:How to create Editable Dropdown List with Dictionary Option using JavaScript?如何使用 JavaScript 创建带有字典选项的可编辑下拉列表?
【发布时间】:2011-01-23 15:47:30
【问题描述】:

例如:-- 当我输入“A”时,所有以 A 开头的元素都应该显示出来……如果是“B”,那么带有 B 的元素……等等)

例如:

    <asp:DropDownList ID="ddlLocation" style="width:140px" runat="server">

    <asp:ListItem Value="1" >India</asp:ListItem>
    <asp:ListItem Value="2" >India - Hyderabad</asp:ListItem>
    <asp:ListItem Value="3">South Africa</asp:ListItem>
    <asp:ListItem Value="4">Australia</asp:ListItem>       

    </asp:DropDownList>

javascript:

function DisplayText()
{
 var textboxId = '<% = txtText.ClientID %>'; 
    var dropdownListId = '<% = ddlLocation.ClientID %>'; 
    document.getElementById(textboxId).value = document.getElementById(dropdownListId).value; 
    document.getElementById(textboxId).focus(); 
}

后面的代码:

ddlLocation.Attributes.Add("onChange", "DisplayText();");

问候 拉维,

【问题讨论】:

    标签: c# .net asp.net javascript dhtml


    【解决方案1】:

    您可能想要使用 jQuery 自动完成功能或ExtJs ComboBox

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 2013-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-02
      相关资源
      最近更新 更多