Handling Dynamic Form Creation with Unique IDs and Maintaining Input Values

I created a div and added a button underneath it. Every time I click the button, I insert values into an array, and then I display those values as items. The number of divs shown corresponds to the number of times the button is clicked. However, the biggest issue is that when I store the div in the array, the form input values are not triggered. No matter what I write in the input fields, they remain empty. This issue is caused by the array.

Please help me so that when I click the button, a form div opens with a unique ID, like sample 1. Then, when I click again, the div is cloned with a unique ID like sample 2, and so on. The input values in the form must be triggered and displayed, whatever I write in the input fields.