English 中文(简体)
进入Button电台 点击使用jquery和肢解的数值,使文字箱照样,Asp.net mvc
原标题:Get the RadioButton Value on click using jquery and disabling, enabling text boxes accordingly, Asp.net mvc

我有两个无线电台

投入类型:无线电名称=“水平”价值=“P”

投入类型:无线电名称=“水平”价值=“S”

我有两个文本箱:

投入类型=“文本”名称=“inpu11”残疾=“残疾”

投入类型=“文本”名称=“inpu12”残疾=“残疾”

我的问题是,

How Can I identify to which button I ve selected ? How can I retrieve the selected radio Id ? I need to enable the first textbox if the selected value is "P" and disabled if S

问题回答

你提出了3个问题。 我要首先回答第三个问题。 你能够以简明扼要的方式这样做。

观点:

<form action= /MyController/MyAction  method= post >
    <div>
        <input type= radio  name= selectRadios  value= P  />
        <input type= text  name= firstTextBox  value= P  />
    </div>

    <div>
        <input type= radio  name= selectRadios  value= S  />
        <input type= text  name= secondTextBox  value= S  />
    </div>

    <input type= submit  value= Submit Values to ActionMethod  />
</form>

<script type= text/javascript >
    $(document).ready(function() {
        $("input[name=selectRadios]").click(function() {
            switch($(this).val()) {
                case  S :
                    $("input[name=firstTextBox]").attr("disabled", "disabled");    
                    break;
                case  P :
                    $("input[name=firstTextBox]").attr("disabled", "");    
                    break;
            }
        });
    });
</script>

我认为,我的第一和第二个问题将很容易地得到真相与和解委员会模拟者的回答。

我的主计长.cs(只有行动方法):

//argument names match form element names from view.aspx
public ActionResult MyAction(string selectRadios, string firstTextBox, string secondTextBox)
{
    //do something with your form values
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签