Hi,
habe mal ein kurze Frage. Und zwar versuche ich mit create Element mehrere Selects mit Inhalt(options) zu füllen.
irgendwie wird aber jedesmal nur das letzte select gefüllt an dem ich appendChild(option) anwende.
Kann mir jemand erklären, warum das so ist? und wie ich mehrere mit Inhalt füllen kann?
Danke schonmal
var selects = document.querySelector('#lists_trips');
var selects_cont = document.querySelector('#lists_cont');
var selects_region_macro = document.querySelector('#lists_reg_mac');
var selects_land = document.querySelector('#lists_land');
var selects_region_micro = document.querySelector('#lists_reg_mic');
var ul_list_element = document.querySelector('.ul_list');
var ul_list_continent = document.querySelector('#continents_nav');
//console.log(ul_list_continent);
//console.log(selects)
window.onload = function () {
//console.log('Dokument geladen');
trips= output1.textContent;
trips= JSON.parse(trips);
//console.log(trips)
for(let x = 0;x<trips.list_trips.length;x++){
let option = document.createElement('option');
if(trips.list_trips[x].list_type = "0"){
//console.log('x')
//console.log(x)
//console.log(trips.list_trips[x])
option.classList.add("style_list_trip");
}
else if (trips.list_trips[x].list_type = "1"){
option.classList.add("style_list");
}
let tempNode =
document.createTextNode(trips.list_trips[x].name);
option.appendChild(tempNode);
selects.appendChild(option);
selects_land.appendChild(option);
}