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

234
Vistas
Why is my Javascript function displaying my text as "null" when using createNodeText?

I'm creating a program which takes user input inside one html page and transfers that text into another html page. Here is my javascript code:

function fromIndex() {
    let b = document.getElementById("textbox").value;
    sessionStorage.setItem("textbox", b)
    console.log(b)
    
    let b2 = document.getElementById("bio").value;
    sessionStorage.setItem("bio", b2)
    console.log(b2)
}

function transferIndex() {
    var h = document.createElement("p");
    let t = document.createTextNode(sessionStorage.getItem("textbox"));
    h.appendChild(t);
    document.body.appendChild(h);

    var h2 = document.createElement("p");
    let getIndex2 = document.createTextNode(sessionStorage.getItem("bio"));
    h2.appendChild(getIndex2);
    document.body.appendChild(h2);
}

The issue I run into is that when the user clicks on the "Update" button on the second html page, the text the user inputted in the first page defaults to "null". For reference, the button in the first html page (transmitting page) calls the fromIndex() function, and the second html page button (the receiving page) calls the transferIndex() function.

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