在下拉列表中调用javascript更改选定的索引 [英] Call javascript on dropdown selected index change

查看:61
本文介绍了在下拉列表中调用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:dropdown
内使用onchange属性
Use attribute onchange inside asp:dropdown

<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.


您好,亲爱的,

您可以通过添加
在设计页面本身中调用Java脚本函数.
onselectedIndexChanged ="function();"

希望它能帮助您在选定的索引更改事件上调用javascript函数.
Hello Dear,

You can call the java script function in the design page itself by adding

onselectedIndexChanged="function();"

Hope it will help you to call the javascript function on selected index changed event.


这篇关于在下拉列表中调用javascript更改选定的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆