I have a set of dynamically built checkboxes (sub-categories of main-category).
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">first</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">second</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">third</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">forth</input>
Now when I submit the form, when I return back to the form from Server (if didn't pass validation, for example) I would like to be able to reconstruct that list of checkboxes with their values. Assume that the first two checkboxes were checked by the user I would like to have something like this:
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700" checked>first</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700" checked>second</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">third</input>
<input type="checkbox" name="SubCats" class="subcat-checkbox" value="18001700">forth</input>
I assume that I do that as one of the first things here:
(document).ready(function () {
loadSubCategories();
}
I am using ASP.NET MVC and I can't figure out how do I deliver that information into the View (the HTML). I assume this is a common task in web development. How is it done in general?
Aucun commentaire:
Enregistrer un commentaire