I have this function which generates a number of inputs based on the user's choice:
// Number of inputs to create
var number = document.getElementById("cantidadArreglos").value;
// Container <div> where dynamic content will be placed
var container = document.getElementById("container");
// Clear previous contents of the container
while (container.hasChildNodes()) {
container.removeChild(container.lastChild);
}
for (i=0;i<number;i++){
// Append a node with a random text
container.appendChild(document.createTextNode("Arreglo #" + (i+1)));
// Create an <input> element, set its type and name attributes
var input = document.createElement("input");
input.type = "number";
input.name = "arreglo" + i;
container.appendChild(input);
// Append a line break
container.appendChild(document.createElement("br"));
}
}
And it works perfectly. However, I will need to use the values introduced by the user on other functions. How can I call them properly?