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")
}
Also in JavaScript:
- speedtest-net node.js
- how to disable all buttons in javascript
- bootstrap cdn for jquery
- destruction in javascript
- javascript extract date from string
- javascript swap array elements
- How to change htm h1 from nodejs
- if condition in class angular 8
- arr.sort
- FAILURE: Build failed with an exception react native android
- plus minus hackerrank solution javascript
- jquery get data attribute
- build apk react native
- javascript count element in array
- how to add carousel in javascript
- local storage javascript array
- redux saga fetch data using axios
- JavaScript: Manipulating Complex Objects
- show ... in 2nd line javascript
- react hook usestate
- how to destructure complex objects
- formidable
- how to pass custom regex in jquery validation
- get count of div by class