繁体   English   中英

如何使用JavaScript使用字典选项创建可编辑下拉列表?

[英]How to create Editable Dropdown List with Dictionary Option using JavaScript?

例如:-当我键入“ 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();");

问候ravi,

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM