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

184
Visualizações
How to read firestore numeric value to text field in php Javascript

I have a numeric firestore value called 1_star. What i trying to do is to retrieve the 1_star value and show it on my text field. But everytime when I want to retrieve it keep showing me error Uncaught SyntaxError: Numeric separators are not allowed at the end of numeric literal. My html text id is called star1

My code (Javascript):

db.collection("PRODUCTS").doc(pageTitle).get().then((doc) => {
    
    if (doc.exists) {
   
        document.getElementById("star1").value = doc.data().1_star;

    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch((error) => {
    console.log("Error getting document:", error);
});

My firestore value:

enter image description here

My html :

  <div class="col-sm-2">
                        <input
                          type="number"
                          class="form-control"
                          id="star1"
                          placeholder="1_Star"
                          name="star1"
                          required
                        />
                      </div>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you are using the type text attribute for your Input field. You can solve your problem using two methods:

1- Change your input type to number.

2- Convert your data to String using toString(); function if your data type is a number:

db.collection("PRODUCTS").doc(pageTitle).get().then((doc) => {
    
    if (doc.exists) {
   
        document.getElementById("star1").value = doc.data().1_star.toString();

    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch((error) => {
    console.log("Error getting document:", error);
});

Because of you did not share your HTML code I think this might solve your problem.

about 4 years ago · Juan Pablo Isaza Relatório
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