Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda