如何将所选单选按钮的值传递给控制器 [英] how to pass the value of the selected radio button into controller
本文介绍了如何将所选单选按钮的值传递给控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在将javascript中的单选按钮的选中/选中值传递给我的控制器时遇到了问题。我有4个单选按钮:
< input type = radio name = 查询 id = reservation / > 预订
< 输入 类型 = radio name = 查询 id = menu_price / > 菜单价格
< 输入 type = radio 名称 = 查询 id = set_menu / > 设置菜单
< 输入 type = radio 名称 = 查询 id = 其他 / > 其他
解决方案
你好,
你有2个选择。
1)你必须使用该输入类型的模型。
@ Html.RadioButtonFor(model => model.Reservation,false)预订
@ Html.RadioButtonFor(model => model.MenuPrice,true)菜单价格
@ Html.RadioButtonFor(model => model.SetMenu,false)设置菜单
@ Html.RadioButtonFor(model => model.Others,true)其他
2)你必须在html中使用checked属性。
(function(){
('#rb2')。change(function(){
if (
I had a problem in passing the checked / selected value of my radio button in javascript to my controller. I have 4 radio buttons:
<input type="radio" name="inquiries" id = "reservation" /> Reservation
<input type="radio" name="inquiries" id = "menu_price" /> Menu Price
<input type="radio" name="inquiries" id = "set_menu" /> Set Menu
<input type="radio" name="inquiries" id = "others" /> Others
解决方案
Hello,
You have 2 options.
1) you have to use model for that input type.
@Html.RadioButtonFor(model => model.Reservation, "false") Reservation
@Html.RadioButtonFor(model => model.MenuPrice, "true") Menu Price
@Html.RadioButtonFor(model => model.SetMenu, "false") Set Menu
@Html.RadioButtonFor(model => model.Others, "true") Others
2) you have to use checked attribute in html.
(function(){
('#rb2').change(function() {
if(
这篇关于如何将所选单选按钮的值传递给控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文