Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!