Are you using a database?
One way to do it is to get the selected results into a recordset and add to cart with add to cart from Recordset.
Maybe name your quantity column something like "Quantity_{ID}" where ID matches the ID in the recordset so you can reference the associated form field.