create datalist dynamically javascript code example
Example 1: create javascript array from datalist dynamically
var my_list=document.getElementById("months");
alert(my_list.options.length);
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);