Populate a Select component via Javascript ou JQuery
I need to make a loop (for) for populate a SELECT component in real time.
What proprities that I will have to use for make this?
In browser in the web page I did:
Code: Select all
var campo_select = document.getElementById('mecanico');
campo_select.options.length = 0;
for (var i = 0; i < jsonData.mecanico.length; i++) {
var counter = jsonData.mecanico[i];
campo_select.options[i] = new Option(counter.mecanico_name, counter.mecanico_id);
}