how can i change selected value of drop list dynamically

Posted by Deepak Gupta on Stack Overflow See other posts from Stack Overflow or by Deepak Gupta
Published on 2011-10-04T11:22:44Z Indexed on 2011/11/16 17:51 UTC
Read the original article Hit count: 264

Filed under:
|

i want to pick the value from text box and then change the value of dropdown list according to that value

<html>
    <head>
        <script>
            function change()
            {
                var value = document.getElementById('text').value;
                document.getElementById("Model").selectedvalue = value
            }
        </script>
    </head>
    <body>
        <asp:DropDownList ID="Model" AutoPostBack="false" runat="server" CssClass="styled">
            <asp:ListItem Value="None">None</asp:ListItem>
            <asp:ListItem Value="Enum">Enum</asp:ListItem>
            <asp:ListItem Value="Sum">Sum</asp:ListItem>
            <asp:ListItem Value="Multi">Multi</asp:ListItem>
            <asp:ListItem Value="Xaxis">Xaxis</asp:ListItem>
        </asp:DropDownList>
        <input id="text" type="text"/>
        <input type="button" onclick="change();"/>
    </body>
<html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET