showing results for - "populate dropdown with a variable"
Cristina
08 Oct 2020
1/* HTML:
2<select id="myoptions">
3
4</select>
5*/
6
7// Javascript:
8var x = "Jenny,John,Stephanie,Marc,Ryan,Jessica";
9
10var options = x.split(",");
11
12var select = document.getElementById('myoptions');
13for(var i=0; i<options.length; i++)
14{
15  select.options[i] = new Option(options[i], i);  //new Option("Text", "Value")
16}