I have a hidden boolean field :
@Html.HiddenFor(x => x.IsTurkey)
In jQuery script I try to change it:
$("@Html.IdFor(x => x.IsTurkey)").val("False");
But on the post back IsTurkey is not changed:
HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Search(TurkeyModel model)
{ ...}
Using jQuery as above, how do I change the value of a hidden boolean field in MVC 4 ?
Make sure you include a leading # in the Jquery selector, as the MVC HtmlHelper does not output it.
I'm not sure your exact code for
IdFor
, but you can simply do: