簡體   English   中英

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

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM