JS获取DropDownList的value与text值

<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>

<script type="text/javascript" language="javascript">
    function SearchChange()
    {
        var ddl = document.getElementById("DropDownList1")  
        var index = ddl.selectedIndex;  
           
        var Value = ddl.options[index].value;  
        var Text = ddl.options[index].text;
       
        alert(Value);
    }
    </script>  

posted on 2010-06-28 13:50  一路前行  阅读(297)  评论(0编辑  收藏  举报