Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Guardar mensaje después de enviarlo en sessionStorage

Tengo una función que muestra un texto después de enviar el formulario y ocultar el formulario:

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

Ahora quiero guardar este mensaje después de actualizar el sitio usando el almacenamiento de sesiones, pero no tengo una idea completa de cómo funciona y no entiendo la idea.

Solo quiero no darle a un usuario la opción de enviar otro formulario a menos que cierre su navegador.

en 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 answers
Answer question

0

Lo haría así: establezca la variable en sessionStorage en su función de change() ; y renderizar los elementos condicionalmente, dependiendo de este conjunto de variables:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!