Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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")
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: adonis hook 
Javascript :: change browser image react 
Javascript :: protractor element.all for each 
Javascript :: get selected option value jquery 
Javascript :: javascript regex replace all 
Javascript :: react scroll to top 
Javascript :: how to pass an object directly to formdata in javascript 
Javascript :: javascript div id add class 
Javascript :: jquery append after 
Javascript :: javascript get users location 
Javascript :: find array javascript 
Javascript :: bootstrap modal popup disable click outside 
Javascript :: public class NameOf { public static String nameof<T(Expression<Func<T name) { MemberExpression expressionBody = (MemberExpression)name.Body; return expressionBody.Member.Name; } } 
Javascript :: uuid v4 
Javascript :: javascript get name of element 
Javascript :: add search query in express 
Javascript :: javascript remove all child elements 
Javascript :: convert number to array javascript 
Javascript :: codeigniter 3 return json response 
Javascript :: hnazmul 
Javascript :: find the key of a value in array js 
Javascript :: javascript object to json string 
Javascript :: nestjs cors origin 
Javascript :: fb login npm 
Javascript :: read file javascript 
Javascript :: js toisostring 
Javascript :: refresh a page in jquery 
Javascript :: sort array of objects javascript by value 
Javascript :: js redirect code 
Javascript :: function expression and function declaration 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =