I tried to make <option>
s with the content in a select tag using a for loop
var content = {
0: "water"
1: "tea"
2: "coffee"
3: "soda"
};
var selectTest = document.getElementById("test");
var createOpption = document.createElement("option");
var addOptionContent;
for (var i = 0; i < content.lenght; i++) {
addOptionContent = document.createTextNode(content[i]);
createOpption.appendChild(addOptionContent);
selectTest.appendChild(createOpption);
}
<select id="test"></select>
I expect that each content will be in its own option tag but the result is that all content was in one option tag