JS获取DropDownList的value值与text值的示例代码
更新时间:2014年01月07日 09:29:23 作者:
本篇文章主要是对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 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>
调用:
复制代码 代码如下:
<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
您可能感兴趣的文章:
相关文章
JavaScript声明变量的这四兄弟(var、let、function、const)
这篇文章主要介绍了JavaScript声明变量的这四兄弟,主要就是介绍var、let、function、const区别,需要的朋友可以参考下2023-02-02
JavaScript setinterval延迟一秒解决方案
这篇文章主要介绍了JavaScript setinterval延迟一秒解决方案,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下2021-09-09
JavaScript数组扁平转树形结构数据(Tree)的实现
本文主要介绍了JavaScript数组扁平转树形结构数据(Tree)的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2022-08-08


最新评论