asp.net mvc - Getting Posted Data from a Dynamic Form with MVC -
i have page contains form, part of dynamically generated based off of sku's on order.
<% each in viewdata.model %> <script type="text/javascript"> $(function () { $('#return_<%=i.skun%>').change(function () { if ($('#return_<%=i.skun%>').val() > $('#qty_<%=i.skun%>').val()) { $('#discrepancy').val("yes"); } else { $('#discrepancy').val(""); } }); }); </script> <tr> <td style="text-align: left"><%= i.skun%></td> <td style="text-align: left; width: 360px"><%= i.descr%></td> <td style="text-align: left">£<%= i.pric%></td> <td style="text-align: left"><%= i.quan%></td> <td style="text-align: left">£<%= i.extp%></td> <td style="text-align: left"><input type="hidden" name="qty_<%=i.skun%>" id="qty_<%=i.skun%>" value="<%= i.quan%>"/><input type="text" name="return_<%=i.skun%>" id="return_<%=i.skun%>" style="width:50px;" class="required"/> <% if i.flag3 = "t" %> <img src="../../content/images/icons/error.png" alt="this sku subject <%=html.viewdata("restockfee") %>% restocking fee" title="this sku subject <%=html.viewdata("restockfee") %>% restocking fee"/><% end if%> </td> </tr> <% next%>
it's no means perfect, gets job done @ moment.
the part i'm struggling return_<%=i.skun%>
series of dynamically generated text boxes change each order, though remain naming convention of return_<%=i.skun%>
, how values them in controller handles form post?
edit: it's important note none of these fields required fields , number of text boxes varies per order.
can't change naming convention to:
<input type="text" name="skuns[<%= index %>]" id="return_<%= i.skun %>" style="width:50px;" class="required" value="<%= i.skun %>" />
where index
incrementing variable 0 n. way controller action this:
public function result(skuns string()) actionresult
and leave default model binder job.
Comments
Post a Comment