![](/img/trans.png)
[英]change text of label on onchange event of @Html.TextboxFor in mvc3
[英]I need to use the “onchange” event inside @Html.RadioButton.[MVC]
我需要在@Html.RadioButton.[MVC] 中使用onchange
事件我有一個函數 exp
function FoncExamp() {
if (document.ExpForm.K_T[0].checked == true) {
document.getElementById("EK").style.display = "block";
document.getElementById("YK").style.display = "none";
}
else {
document.getElementById("EK").style.display = "none";
document.getElementById("YK").style.display = "block";
}
}
我需要在@html.radiobuttons 上調用這個函數
@using (Html.BeginForm(null, null, FormMethod.Post, new { name = "ExpForm" }))
{
<div class="container well">
<div class="form-group row">
<label class="col-md-2">EK @Html.RadioButton("K_T", "E_K")</label>
<label class="col-md-2">YK @Html.RadioButton("K_T", "Y_K", new { @checked = true })</label>
</div>
您可以將 onchange 事件添加到 htmlAttributes
<label class="col-md-2">EK @Html.RadioButton("K_T", "E_K", new { onchange = "FoncExamp(this)" })</label>
<label class="col-md-2">YK @Html.RadioButton("K_T", "Y_K", new { @checked = true , onchange = "FoncExamp(this)"})</label>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.