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

105
Views
¿Cómo transfiero un valor entre páginas web utilizando el almacenamiento local?

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>SwinTech</title> </head> <body> <form action="apply.html" method="post"> <div class="consultantinformation"> <h2> Job reference number: </h2> <br> <h4 id="jobreference2"> 6LZ9W </h4> </div> <button id="submitbutton">Submit</button> </form> <script> document.getElementById("submitbutton").addEventListener("click", setItem); localStorage.setItem("jobreference1", "1FN43"); </script> </body> </html>

Estoy tratando de transferir "jobreference1" del primer fragmento al segundo usando el almacenamiento local. Como puede ver, lo almacené en un archivo JavaScript externo y lo envié a otro. Pero cuando trato de llamarlo en el código HTML en el segundo fragmento, al que se transfirió el valor, simplemente no funciona. Decidí incluir todo mi código HTML y JavaScript para mi segundo fragmento porque creo que ahí es donde radica el problema. Gracias.

Nota: no hay JavaScript en línea ni jQuery.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este es un ejemplo de trabajo. El index.html establece la referencia en la carga de la página. El envío del formulario redirige a apply.html y lee el valor correcto al cargar la página.

índice.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>SwinTech</title> </head> <body> <form action="apply.html" method="post"> <div class="consultantinformation"> <h2> Job reference number: </h2> <br> <h4 id="jobreference2"> 6LZ9W </h4> </div> <button>Submit</button> </form> <script> localStorage.setItem("jobreference1", "1FN43"); </script> </body> </html>

aplicar.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p>Job Reference Number: <span id="job1"></span></p> <script> document.getElementById("job1").innerHTML = localStorage.getItem("jobreference1"); </script> </body> </html>
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!