I am trying to create a dynamic list of options, I have an array where I contain the data I want. My idea is to make a for, giving it the length of the array and creating the options inside, but when doing so it doesn't work for me and it only creates an option.
addEventListener('load', inicio, false);
function inicio(){
var dato = document.getElementById("dato1").value;
var boton = document.getElementById("b_enviar");
var b_a = document.getElementById("b_crear");
var datos = new Array();
boton.addEventListener('click', function(){
datos.push(document.getElementById("dato1").value);
console.log(datos);
}, false);
b_crear.addEventListener('click', function(){
var section1 = document.getElementById('section1');
var section2 = document.getElementById('section2');
var select = document.createElement('select');
var option = document.createElement('option');
var s1 = section1.appendChild(select);
for (let index = 0; index < datos.length; index++) {
s1.appendChild(option);
console.log(index);
}
}, false);
}