I have the following table where a user can choose some quanitity for a corresponding item.
What is the simplest way to send this data to the server without using JavaScript?
Right now I am creating a data-name
with item's name on each quantity input field. Then grabbing all those input fields, followed by the $.post
request (not shown here).
var items = [];
var $quantities = $('.quantity');
$.each($quantities, function(index, input) {
items.push({
name: $(input).data('name'),
quantity: $(input).val()
});
});
I am curious to know if there is a more elegant approach to do this with just using the HTML form
element.
Edit: I am free to choose whatever model I see fit. No constraints there since this is a fresh from the start personal project.