Add/Remove Line Property Item based on Quantity

Hello!

I’m trying to look for a code snippet or a tutorial on how to add/remove line property item based on quantity.

I have name and email address to add. So if the customer chooses 1 quantity, the default is one text field for each. If the customer chooses 2, then another set of text fields will appear, and so on. Same with reducing quantity.

I found this tutorial but it’s only for a fixed line property item/s.

How can I achieve this? If only by Javascript, how can I pass the input fields up to the cart page and checkout?

Here’s the vid to explain.

Thank you very much!

@devsbh what you are trying to achieve is possible. Though, I’ve never seen someone doing that before. It’s possible with JQuery if you know that you may want to use the eventListener property to check quantity change and run a function on each listen. In the function, you want to run for loop to create the DOM input element.

Hope it makes sense.