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 兼容FF的onmouseenter和onmouseleave的代码
经过测试发现,例子1 在 ff下抖动的厉害,ie下稍微有点。 具体原因 其实就是 mouseout 的冒泡机制 引起的。2008-07-07
最新评论