Creating and deleting form fields dynamically

I needed a form that allows the user to add and remove products with quantities as he wishes.
The form had one row with a product and quantity inputs that I decided to clone each time, change the id to an incremented id, remove the value from the field and update the input names.
This is what I did:

I added the increment variable’s value to a hidden field so I could retrieve him in the processing script:

The processing file used the following code:

Leave a Reply

Your email address will not be published. Required fields are marked *