您的位置:首页 > 产品设计 > UI/UE

JS获取DropDownList的value值与text值的示例代码

2018-10-12 13:55 916 查看
相关JS:

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

调用:

<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

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: