javascript change select options dynamically

Solutions on MaxInterview for javascript change select options dynamically by the best coders in the world

showing results for - "javascript change select options dynamically"
Gauthier
28 Oct 2017
1function getType() {
2  var x = document.getElementById("food").value;
3  var items;
4  if (x === "fruit") {
5    items = ["Apple", "Oranges", "Bananas"];
6  } else {
7    items = ["Eggplants", "Olives"]
8  }
9  var str = ""
10  for (var item of items) {
11    str += "<option>" + item + "</option>"
12  }
13  document.getElementById("pickone").innerHTML = str;
14}
15document.getElementById("btn").addEventListener("click", getType);
queries leading to this page
add select options dynamically javascripthow to change select options with javascriptset select value dynamically in javascprithow to change select html in form dynamicallyjavascript dynamically select optionhow to add select options dynamically using javascriptdynamically create select option in javascriptjavascript change select optionselect option dynamically jschange select options javascripthow to change select value dynamicallyjs dynamic select optionhow to dynamically select option in select htmljavascript change select dynamicallydynamically change select option in javascriptjavascript set select options dynamicallyjavascript add select options dynamicallyhow to dynamically change html selectdynamically create options with selected javascriptdynamically select value html select jsjavascript add options to select dynamicallyhow to add select option dynamically javascripthow to set select option value dynamically in htmldynamically add options to select javascriptdynamically add select options in javascriptjavascript change select option style dynamichow to dynamically add options in select in javascripthow to dynamically set selectjs change select option dynamicjavascript change select option dynamically how to make select dropdown option dynamically in javascriptjavascript dynamic change select optionjavascript select box dynamically add optionschanging select options dynamicallyjs change select optionscreate select option dynamically javascripthow to set select option value dynamically in javascriptjavascript create select option dynamicallyadding select options dynamically javascriptjs add select option dynamicallydynamicaaly change select tag option selction jshow to add options to select in javascript dynamicallyhow to create select option dynamically in javascriptjs how to select dynamically a selectdynamically set select tag option javascriptjavascript select option selected dynamicallyjavascript change select options dynamicallyhow to change select option dynamically with jsdynamic select box replace options onchange vanilla jsjavascript set selected option dynamicallyjavascript programmatically change select optionjavascript select option add dynamicallychanging select box id dynamicallyjavascript dynamically add options to selectset value of select options dynamically in jshtml change select option dynamicallydynamically change options based on select javascripthow to dynamically set options in select in javascripthow to html select option dynamically with jsjavascript select option dynamic changeadd options to select javascript dynamicallyhow to dynamically change the options in select javascripthow to dynamically change the options in selecthow to change select options in javascriptjavascript change select optionshow to set options in select dynamically using javascript select option dynamically javascripthow to dynamically add select options in javascriptjs dynamically add options to selectdynamically select option on select jsset select options dynamiv in javascriptdynamic select option in javascripthtml dynamic select options jsjavascript change select options dynamically