Set dropdown text selected from textbox value

In some cases we need to set dropdown list items exact text by matching the value entered in textbox. For that purpose we can use .keyup event in jQuery. In .keyup event simply take the value of textbox and assign that value to the value of dropdown. Once you set value it's corresponding text will be get displayed as selected.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head id="Head1" runat="server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <title>Get dropdown value</title>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#topics").keyup(function () {
                var value = $("#topics").val();
                if (value == "" || isNaN(value))
                    value = 0;
    <form id="form1" runat="server">
    <asp:TextBox runat="server" ID="topics"></asp:TextBox>
      <asp:DropDownList ID="topics1" runat="server">
     <asp:ListItem Text="--Select--" Value="0"></asp:ListItem>
    <asp:ListItem Text="C#" Value="1"></asp:ListItem>
    <asp:ListItem Text="jQuery" Value="2"></asp:ListItem>
    <asp:ListItem Text="ASP.NET" Value="3"></asp:ListItem>

Note: You may need some additional validations if user enters data in textbox that does not match to the values in dropdown. Ex. I have just validated in above code if user enters characters other than number using IsNaN


  1. very useful information you are did about Set dropdown text selected from textbox value . keep update more information for us.
    Dotnet Training in Chennai


  2. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    DotNet Training in Chennai


  3. I read your articles very excellent and the i agree our all points because all is very good information provided this through in the post. It is very helpful for me. Keep blogging like this. Thanks.

    SAP training in Chennai

  4. You have told another data which is useful and i assembled learning about this subject so please overhaul data more upgrade this theme.
    DOTNET Training in Chennai | dotnet training institutes in Chennai | .net training Chennai | .net course in Chennai

  5. Thanks for sharing these niche piece of knowledge. Here, I had a solution for my inconclusive problems & it’s really helps me a lot keep updates…
    web design training chennai|Best web designing institute in chennai