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

101
Visualizações
javascript Array not inserting and displaying in a dropdown menu

im trying to get the document ID values from my firestore and insert them to my dropdown menu,however when i try to do that the dropdown menu is empty,even tho when i console.log the array where i stored the values,it shows all the values correctly.here is my code.

db.collection("Points").onSnapshot((querySnapshot) => {
    arr = [];
    querySnapshot.forEach((doc) => {
        arr.push(doc.id);
    });
    var select = document.getElementById("point");
    for (var i = 0; i < arr.length; i++) {
        var option = document.createElement("OPTION"),
            txt = document.createTextNode(arr[i]);
        option.appendChild(txt);
        option.setAttribute("value", arr[i]);
        select.insertBefore(option, select.lastChild);
        //console.log(points);
        console.log(arr[i]);
    }

});

and the html:

<select name="point" id="point" class="browser-default selectit">
          <option value="">Selectionner un point </option>
      </select>

and this is what i see in my console for the when i check the console.log of my array console view

any help would be appreciated,thanks

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