Adding options to select with javascript

I want this javascript to create options from 12 to 100 in a select with id=”mainSelect”, because I do not want to create all of the option tags manually. Can you give me some pointers? Thanks

function selectOptionCreate() {

  var age = 88;
  line = "";
  for (var i = 0; i < 90; i++) {
    line += "<option>";
    line += age + i;
    line += "</option>";
  }

  return line;
}

9 Answers
9

Leave a Comment