Answers for "how to call a function when dropdown menu's value is selected in html"

0

how to call a function when dropdown menu's value is selected in html

var menu = document.getElementById("change_chart");
menu.addEventListener("change", generateData);

function generateData(event) {
  if (menu.value == '1') {
    alert(1);
  } else if (menu.value == '2') {
    alert(2);
  } else if (menu.value == '3') {
    alert(3);
  }
}
Posted by: Guest on December-22-2020

Code answers related to "how to call a function when dropdown menu's value is selected in html"

Browse Popular Code Answers by Language