populate dropdown with preselected variable code example
Example: populate dropdown with a variable
/* HTML:
<select id="myoptions">
</select>
*/
// Javascript:
var x = "Jenny,John,Stephanie,Marc,Ryan,Jessica";
var options = x.split(",");
var select = document.getElementById('myoptions');
for(var i=0; i<options.length; i++)
{
select.options[i] = new Option(options[i], i); //new Option("Text", "Value")
}