Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had a problem in passing the checked / selected value of my radio button in javascript to my controller. I have 4 radio buttons:
HTML
<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
Posted
Updated 17-Jun-14 22:11pm
v3

1 solution

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($(this).is(':checked')){
$("#txt2").prop("disabled", true);
}
else
{
$("#txt2").removeAttr("disabled");
}
})
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900