JavaScript Implementation select Add option


JavaScript adds option to select

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> The test file </title>
<script>
window.onload = function(){
  // create select controls
  var _select = document.createElement("SELECT");

  // Add a option
  for(var i=1; i<=10; i++){
    var _option = new Option(i,i);
    _select.options.add(_option);
  }

  // The handler when the selected value changes
  _select.onchange = function(){
    alert(_select.value); // take select Control is the selected value
  }

  document.body.appendChild(_select);
}
</script>
</head>

<body>
</body>
</html>

This is the end of this article, I hope you enjoy it.