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

227
Visualizações
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 Respostas
Responde à pergunta

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 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