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

219
Views
How to put data from firebase database into input text field?

Hello I would like to ask if how to put data from firebase database into input text field? I tried it in any text label like, Label, h1, strong or anything and they getting it but when I put it in input text field its not changing or detecting.

This is the code my input text field.

<div class="md-input">
<label>First Name<span class="text-danger">*</span></label><br>
<div class="md-input">
<input class="md-form-control" type="text" id="firstname" name="firstname" placeholder="&nbsp;" required>
</div>

and this is the javascript or my firebase code to move it in the input field but nothings happening.

firebase.auth().onAuthStateChanged(function(user)
  {
      if(!user)
      {
          window.location.href = "../signin.html";
      }
      else 
      {
        var dbUser = firebase.auth().currentUser.uid;

    firebase.database().ref('Freelancer/' + dbUser).once('value').then(function (snapshot){

    var okay = snapshot.val().name;
    var okay1 = snapshot.val().email;
    var okay2 = snapshot.val().pass;
    var okay3 = snapshot.val().roles;
    var okay4 = snapshot.val().userID;

    console.log(okay);
    console.log(okay1);
    console.log(okay2);
    console.log(okay3);
    console.log(okay4);


    document.getElementById("firstname").innerHTML=okay;
    document.getElementById("lastname").innerHTML=okay1;
    document.getElementById("phone").innerHTML=okay2;
    document.getElementById("roles").innerHTML=okay3;

});

Hope someone can assist me or help me thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For <input> elements, you need to use the value property when setting (or getting) the text in the field.

document.getElementById("firstname").value = okay;
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!