I have a Select box and I want to add the content of it through JS from an array.
I am trying to add the content but I am getting document.getElementById("fldbillerid") is null
.
Below is my code. Any help or suggestion will be appreciated.
HTML
<select name="fldbillerid" id="fldbillerid" class="objselect" maxlength="35">
<option value="S">Select</option>
</select>
JS
mybillerid = ["1", "2", "3", "4", "5"];
var select1 = document.getElementById("fldbillerid");
for (var i = 0; i & lt; mybillerid.length; i++) {
var opt = mybillerid[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select1.appendChild(el);
}