我在下拉菜单更改时调用名为 ChangeCurrency(ID)
的函数。我需要函数 ChangeCurrency(ID)
中下拉列表的 ID。但不幸的是在 razor 中html 它显示此错误:
PjtCostCurrencyID is undefined.
那么如何将下拉列表的 id 传递给函数。请帮忙。
下面是代码
@Html.DropDownList("PjtCostCurrencyID", null, new { @onchange = "ChangeCurrency($PjtCostCurrencyID)" })
最佳答案
试试这个
@Html.DropDownList("PjtCostCurrencyID", null, new { @onchange = "ChangeCurrency(this)" })
and in function
function ChangeCurrency(_this)
{
var PjtCostCurrencyID =_this.id;
}
关于jquery - 如何在razor html或mvc3中的onchange fn上传递下拉菜单的id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15171404/