php - JavaScript post same name for multiple inputs

one text

Solution:

The id is an unique identifier. The means that your 'id=add_kid()_1' can't repeat for more than one . The class attribute can repeat. In this case, you'll use the class="submit_but" to catch the two input tags.

Then, the first step is extract the info. There's only two inputs to extract info from and they have the tag in common: "submit_but".

const infoElements = document.querySelector('.submit_but');

infoElemnts contains all nodes with class="submit_but".

Here your answer pt1 If you wanna store the info of inputs in an array:

 const infoValues = infoElements.map((element) => {
        return element.value;
    }

Now, infoValues has all inputs values. You can do all this process with yours childs inputs that will be created.

 div.innerHTML = '<input class="dayTour"></input>' 
 div.innerHTML = '<input class="whatever"></input>' 

 const dayTourElements = document.querySelector('.dayTour');
 
 const dayTourValues = dayTourElements.map((element) => {
        return element.value;
 }

Here your answer pt2

I don't how you wanna save this, but for simple approach you can simple write it to your local storage into a '.txt' file.

const fs = require('fs');

fs.appendFile('mynewfile1.txt', 'Hello content!', function (err) {
  if (err) throw err;
  console.log('Saved!');
});

Here tutorial: https://www.w3schools.com/nodejs/nodejs_filesystem.asp

Source