I have a webpage to submit a recipe. There are 5 fields for ingredients. If the recipe needs more than 5 ingredients, there is a button to ‘add another ingredient’ and some java script loads another ingredient input for them to use.
I’m not sure how to POST this data properly to my backend which is MVC4/C#.
Could I give them all the same id=ingredient and collect them as a string ingrdient[]? or whats the best practice to get form inputs when the number of inputs can change?
Thanks.
Ok here is a sample:
You can use this approach:
Now you can get this in your controller using :