As the title says, how can I submit values inside input fields that reside in a table? My table is loaded with razor foreach like:
@foreach (var i in Model)
{
<tr>
<td>@i.Id</td>
<td><input type="text" value="@i.Name" name="Name" /></td>
<td><input type="text" value="@i.Weight" name="Weight" /></td>
<td>
@Html.DropDownListFor(m => m.Gender, Model.DropdownGenders)
</td>
</tr>
}
....
<button type="button">Save Changes</button>
There could be unknown number of rows but what I want to do is when I click the Save Changes button, each row will be transformed into a json string probably like this:
[
{id: 1, name: "name", weight: "weight", gender: "gender"},
{id: 2, name: "name", weight: "weight", gender: "gender"}
..
]
So that I can submit it as a string for deserialization in my MVC controller. Im trying to avoid using any 3rd party libraries except jquery. Help please.