JSFiddle - React, Tailwind, and code Playground
HTML
<select id="supplier">
<option value="1">1</option>
<option value="2">2</option>
</select>
JavaScript
function addOptions(input) {
var sel = document.getElementById("supplier");
if (typeof input === "string") {
input = [input];
}
sel.options.length = 0; // Clears all current options
for (var i = 0; i < input.length; i++) {
sel.options[sel.options.length] = new Option(input[i], input[i]);
// This APPENDS options
}
}
addOptions("fff");