Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
Selectize add Google Sheets array as options

I want to create a searchable dropdown menu to select the available customers from a column in a Google Sheets document.

So far, I have tried to populate the field with options using the below code but I keep getting this error:

Cannot read properties of undefined (reading 'addOption')

The array returns an array in this format:

[[Customer 1], [Customer 2]]

Do you have any idea how to solve the error?

    <script>
      $(function() {    

  $('#customer').selectize({
    delimiter: ',',
    persist: false
  });

});
      (function () {
        google.script.run.withSuccessHandler(
          function (selectList) {
            var $select = $(document.getElementById('customer'));        
            var selectize = $select[0].selectize;
            for( var i=0; i<selectList.length; i++ ) {
              
                selectize.addOption({ value: i+1, text: selectList[i] });
                selectize.addItem(i+1);
                };
          }
        ).getSelectList();
      }());
    </script>
      <div class="form-group row">
    <label for="kunde"class="col-sm-2 col-form-label">Kunde</label>

  </div>
    <div class="col-sm-10">
<select id="customer" placeholder="Select a customer...">
</select>
    </div>      

Code.gs

function getSelectList() {
  try {
    var sheet = SpreadsheetApp.openById("file-id").getSheetByName("Kunden");
    var values = sheet.getRange(2,1,sheet.getLastRow(),1).getValues();
    return values
  }
  catch(err) {
    Logger.log(err);
  }
};
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda