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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2020-05-13 我要评论
相关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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们