首页 > 语言 > JavaScript > 正文

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

2024-05-06 15:59:14
字体:
来源:转载
供稿:网友
本篇文章主要是对JS获取DropDownList的value值与text值的示例代码进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选