I am building a ordering google sheets with custom appscript. I've constructed a way to choose which products are added to an order via a html form that is shown on top of the sheets. The problem that I'm facing is with getting the full list of values out of a dropdown.
The dropdown that I'm using right now is made with this github project: https://github.com/habibmhamadi/multi-select-tag
I'm able to get 1 of the options selected to print in the console (always the first one selected, so if options 3,4,5 are selected -> it prints 3, if 1,2,5 selected -> 1 is printed).
Here's my html form code and also the two buttons at the end are the options I've tried. First one gives 1 value, second one is always null.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reserve calendar</title>
<link rel="stylesheet" href="https://use.typekit.net/wrf4ljb.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/habibmhamadi/multi-select-tag/dist/css/multi-select-tag.css">
<style>
html{height:100%;display:flex;font-size:calc(max(2vw, .85em))}
body{margin:auto;background:#fff;font-family:Cambria,Cochin,Georgia,Times,Times New Roman,serif}
</style>
<script src="https://cdn.jsdelivr.net/gh/habibmhamadi/multi-select-tag/dist/js/multi-select-tag.js"></script>
<script>
const getBikeChoices = (element) => google.script.run
.withSuccessHandler(tulos => console.log('TULOS:', tulos))
.getBikeFields(element)
</script>
</head>
<body>
<fieldset>
<legend>Pyörien valinta</legend>
<label for="bikes">Valitse pyörät:</label>
<select name="Pyörät" id="bikes" size="5" multiple>
<option value="bike1" id="bike1">bike1</option>
<option value="bike2" id="bike2">bike2</option>
<option value="bike3" id="bike3">bike3</option>
<option value="bike4" id="bike4">bike4</option>
<option value="bike5" id="bike5">bike5</option>
</select>
<br>
<button onclick="getBikeChoices(document.getElementById('bikes').value)">Valitse pyörät</button>
<button onclick="getBikeChoices(document.getElementById('bikes')
.addEventListener('change', function(e){
const selectedVals = [...this.selectedOptions].map(o => o.value);
return selectedVals
}
))">Testi nappi</button>
<script>
new MultiSelectTag('bikes')
</script>
</body></html>
and here's my js code which is only inteded as a return function right now (will have more functionality after I get this problem fixed)
const getBikeFields = (element) =>{
return element
}