i've been trying to make a list of names. the names are inputed by enter click. after that it should fill an array which later will be used to shuffle them. as the enter is clicked im trying to add each array child to a styled div.
that's what i tryed so far -
var values = [];
document.getElementById("inputtext").onkeypress = function(event){
if (event.keyCode == 13 || event.which == 13){
var inp = document.getElementById('inputtext');
values.push(inp.value);
inp.value = "";
for(var i = 0; i < values.length; i += 1) {
var udiv = document.createElement("div");
udiv.className = "idiv";
udiv.innerHTML = document.getElementById("inputtext").value;
document.getElementsByClassName('addednames')[0].appendChild(udiv);
}
}
}
i'm not sure that's even the right way hope for more guidance. thanks in advance