Hi I am trying to get a dropdown list using HTML and Google Script. The options should be taken from the Google Spreadsheet. Unfortunately, my list is empty all the time. The options don't appear. Anyone can help?
CODE GS
function getListCars(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var carsheet = ss.getSheetByName("Rejestraut");
var lastrow = carsheet.getLastRow();
return carsheet.getRange(2,2,lastrow-1,1);
}
HTML
...<script>
function loadCars(){
google.script.run.withSuccessHandler(function(ar)
{
var carsSelect = document.getElementById("numeryrejestracyjne");
console.log(ar);
let option = document.createElement("option");
option.value="";
option.text = "";
carsSelect.appendChild(option);
ar.forEach(function(item, index)
{
let option = document.createElement("option");
option.value = item[1];
option.text = item[1];
carsSelect.appendChild("option");
});
}).getListCars();
};
</script>
<select id="numeryrejestracyjne">
</select>
<script>loadCars();</script>