I am trying to fill <select>
from the data stored in a JSON array. My code is as follows:
applications = {
"apps": [
{ "app":"app_uno", "buzon":"buzon_uno" },
{ "app":"app_dos", "buzon":"buzón_dos" }
]
};
function fillSelector(options_list) {
var options = options_list;
var modelList = document.getElementById("select_form");
for (var i in options.apps) {
var opt = options.apps[i].app;
modelList.options.add(opt);
}
}
fillSelector(applications);
<select id="select_form">
<option value="">Seleccione una opción</option>
<select>
In this example I would have to store the values "one", "two", etc. in "opt". I do not know where the problem is since I've never used JSON, this time it's the first time I use it.