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
Often you have an array of related records, I find it easy and fairly declarative to fill select
this way:
selectEl.innerHTML = array.map(c => '').join('');
This will replace existing options.
You can use selectEl.insertAdjacentHTML('afterbegin', str);
to add them to the top instead.
And selectEl.insertAdjacentHTML('beforeend', str);
to add them to the bottom of the list.
IE11 compatible syntax:
array.map(function (c) { return ''; }).join('');