本文介绍了在下拉列表中调用javascript更改选定的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类似tihs的下拉菜单
< asp:DropDownList ID ="cmbexch" runat ="server">
并尝试像这样调用javascript.
在页面加载时,我正在写这行
cmbexch.Attributes.Add("OnSelectedIndexChanged","javascript:fillmkttype()")
但它不起作用
i have a dropdown like tihs
<asp:DropDownList ID="cmbexch" runat="server">
And trying to call javascript like this.
On page load i am writting this line
cmbexch.Attributes.Add("OnSelectedIndexChanged", "javascript:fillmkttype()")
but it is not working
推荐答案
<asp:DropDownList ID="ddShed" Width="120px" onchange="GetBalanceQty(this.options[this.selectedIndex].value);"
runat="server">
</asp:DropDownList>
JavaScript函数----
JavaScript Function----
function GetBalanceQty(val)
{
//in val u get dropdown list selected value
var id = val;
}
谢谢&问候,
沙爹.
Thanks & Regards,
satya.
please mark as answer if helpful.
cmbexch.Attributes.Add("onChange", "return OnSelectedIndexChange();")
<code> OnSelectedIndexChange()</code> should be your Javascript function that will be call <code>DropDownList </code> Seleted index is changes.
像
Something Like
function OnSelectedIndexChange()
{
alert(''index changed'')
}
您还可以传递该对象以获取所选项目的值.
You can also pass the object to get the value of selected item as well.
这篇关于在下拉列表中调用javascript更改选定的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!