JSFiddle - React, Tailwind, and code Playground
HTML
<select name="box" id="box" multiple>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
<option value="d">D</option>
</select>
<button onclick="bla()">Click to display selected items</button>
<script>
function bla() {
var sel = document.getElementById("box");
var sResult = "";
for (var i = 0; i < sel.options.length; i++) {
if (sel.options[i].selected){
sResult += sel.options[i].value + ','
}
}
if (sResult.length > 1) sResult = sResult.substring(0,sResult.length-1);
alert(sResult)
}
</script>