博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

JS获取DropDownList的value值与text值

Posted on 2014-05-28 14:07  木头人Ricky  阅读(413)  评论(0编辑  收藏  举报
<script type="text/javascript" language="javascript">
    function SearchChange()
    {
        var ddl = document.getElementById('<%=DropDownList1.ClientID %>')   
        var index = ddl.selectedIndex;   
         
        var Value = ddl.options[index].value;   
        var Text = ddl.options[index].text;
        
        alert(Value);
    }
    </script>
<asp:DropDownList ID="DropDownList1" runat="server" onchange="SearchChange();">
    <asp:ListItem Value="0">111</asp:ListItem>
    <asp:ListItem Value="1">222</asp:ListItem>
    <asp:ListItem Value="2">333</asp:ListItem>
</asp:DropDownList>