gespeichert ich dieses Skript leite:Versucht, ein Dropdown mit Optionen zu füllen. Es wird nur ein Wert
function insertformat(formats){
//Deletes the content of the dropdown if there was any
document.getElementById('format').options.length = 50;
//fills the dropdown with an associative array
for (var key in formats)
var newOption = "<option value='"+key+"'>"+formats[key]+"</option>";
$("#format").append(newOption);
}
folgende wählen zu füllen:
<select id="format"></select>
jedoch nur das letzte Element des Arrays gespeichert ist. Im Debug-Modus scheint das Dropdown-Menü bei jedem Schleifendurchlauf überschrieben zu werden, anstatt ein neues Element hinzuzufügen.