0
I want to add options to a select tag in JavaScript
I want to add options to a select. I got it working for fixed string been added but when I changed it to variables it adds the first but not subsequent ones. Included are the two versions of the webpage. https://code.sololearn.com/Wnx2YF5cXBN8/?ref=app https://code.sololearn.com/W8UiWoa4Y3hI/?ref=app
3 Respuestas
+ 3
Gray Adamson 
This also works
<!DOCTYPE html>
<html>
<body>
<select id="myList"></select>
<script>
const select = 
 document.getElementById("myList");
 
document.body.onload = function(){
 let i = 1, iMax = 3;       
 while(i<=iMax){
  let node = 
   document.createElement("option");
  node.textContent = i; 
 select.appendChild(node);
 i++;
 }
}
</script>
</body>
</html>
how option values and select action could also be set in js:
https://code.sololearn.com/W8j47iKM17kf/?ref=app
+ 2
https://code.sololearn.com/WTw82Hw987LL/?ref=app
try this
maybe you are using > instead of >= in the for loop
+ 2
Thanks I got it working 
I include my code
https://code.sololearn.com/W8UiWoa4Y3hI/?ref=app



