js populate datalist code example
Example 1: create javascript array from datalist dynamically
var my_list=document.getElementById("months");
my_list.innerHTML = str;
Example 2: javascript array from datalist
var options = document.getElementById('estados').getElementsByTagName('option');
var optionVals = [], i = 0;
for (i; i < options.length; i += 1) {
optionVals.push(options[i].value);
}
console.log(optionVals);