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

173
Visualizações
Saving message after submit in sessionStorage

I have a function which shows a text after submit form and hide form:

function change() {
    document.getElementById('form').style.display ='none';
    document.getElementById('thanks').style.display = '';
}

Now I want to save this message after refresh site using sessionstorage, but I have no completely idea how it works and I don't understand the idea.

I just want to not give an user option to send another form unless he close his browser.

In html:

    <button type="submit"  id="button" onclick="change()">Send</button>
    <input type="reset" id="button">
  </form>
</div>
<h1 id="thanks" style="display:none">Thanks for submit the form!</h1>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I would do it like so: set the variable in sessionStorage in your change() function; and render the elements conditionally, depending on this variable set:

window.onload = isChange;

function change() {
    sessionStorage.setItem('change', true);

    isChange();
}

function isChange() {
    if (sessionStorage.getItem('change')) {
        document.getElementById('form').style.display ='none';
        document.getElementById('thanks').style.display = '';
    } else {
        document.getElementById('form').style.display ='';
        document.getElementById('thanks').style.display = 'none'n
    }
}
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