I have a page that contains a form, where part of it is dynamically generated based off of what SKU's are on an order.
<% for each i 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" Then
%> <img src="../../Content/images/icons/error.png" alt="This SKU is subject to a <%=Html.ViewData("RestockFee") %>% restocking fee" title="This SKU is subject to a <%=Html.ViewData("RestockFee") %>% restocking fee"/><%
End If%>
</td>
</tr>
<% Next%>
It's by no means perfect, but it gets the job done at the moment.
The part I'm struggling with is as return_<%=i.SKUN%>
is a series of dynamically generated text boxes that change for each order, though they remain with the naming convention of return_<%=i.SKUN%>
, how do I get the values for them in my controller that handles the form post?
EDIT: It's also important to note that none of these fields are required fields and that the number of text boxes varies per order.