javascript - radio buttons checked with jquery not holding proper value on post -
i have html form, radio buttons dynamically set jquery. posts asp.net mvc application.
lets have 3 radio buttons, lets value modelbind radiooption
:
name id checked? disabled? model value
- option1 #opt1 ✓ ✗ 0
- option2 #opt2 ✗ ✗ 1
- option3 #opt3 ✗ ✓ 2
and user picks separate option triggers bit of javascript code:
$("#opt1").prop("checked", false); $("#opt1").prop("disabled", true); $("#opt2").prop("checked", false); $("#opt2").prop("disabled", true); $("#opt3").prop("checked", true); $("#opt3").prop("disabled", true);
which (visibly) shows
name id checked? disabled? model value
- option1 #opt1 ✗ ✓ 0
- option2 #opt2 ✗ ✓ 1
- option3 #opt3 ✓ ✓ 2
so user won't able uncheck opt3
now, looks on page, when hit submit button, , take @ glimpse model binding page, value comes in radiooption
not 2
expect, 0
(the original value)
is there way set these radio buttons allow me receive right value?
this due problem option3 field disabled, value won't in post back.
refer disabled radio button losing value after postback more details.
Comments
Post a Comment