Monday, April 8, 2019

Fill html select using javascript array

I want to fill a select with and array values. I don't see why my code doesnt work. I am a beginner.This is my script



    var mes = new Array();
for(i = 0; i < 12; i++){
mes[i] = i;
}


var sel = document.getElementById('mes');
for(var i = 0; i < mes.length; i++) {
var opt = document.createElement('option');
opt.innerHTML = mes[i];
opt.value = mes[i];
sel.appendChild(opt);
}


And this is the html select:




 

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...