How to create Editable Dropdown List with Dictionary Option using JavaScript?...

Posted by kumar on Stack Overflow See other posts from Stack Overflow or by kumar
Published on 2010-03-04T12:06:07Z Indexed on 2010/03/31 10:33 UTC
Read the original article Hit count: 362

Filed under:
|
|
|
|

Hi Guys,

Eg:-- When I type "A" all the elements starting with A should be displayed... If "B" then elements with B....etc)

Ex:

    <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(); 
}

code behind :

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

Regards ravi,

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript