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

232
Visualizações
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 à 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