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