简体   繁体   English

我需要在@Html.RadioButton.[MVC] 中使用“onchange”事件

[英]I need to use the “onchange” event inside @Html.RadioButton.[MVC]

I need to use the onchange event inside @Html.RadioButton.[MVC] I have a function exp我需要在@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";
        }
    }

I need to call this function on @html.radiobuttons我需要在@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>

You can add the onchange event to htmlAttributes您可以将 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM