I have a view where I am showing up to 5 radio buttons as follows:
View foreach(var item in Model.AvailableOptions) { @Html.RadioButtonFor(m => m.Option, item.OptionId, new { Id = item.Id}); }
Model
IList<Options> AvailableOptions {get; set;}
Then I have a javascript on the same view that handles changing some forms on the page, for example if I have 5 radio buttons when i click upon each of them I hide the form and show the next etc..
The problem is that if there are 5 radio buttons and i am on the third one and I submit with some invalid entries in the form, when it returns to the page it sets it to the first radio button as selected. I would like to know which one was selected on the Submit so that I can reset it on the javascript.
i would like something lik (just not sure how to do this)
var selectedValue = '@(int)Model.SomehowRetrieveTheValuePosted';
Then I would be able to do:
jQuery(".radioOptions")[selectedValue].show();
or something like that.
Aucun commentaire:
Enregistrer un commentaire