Pick up value typed using Javascript

Asked

Viewed 72 times

-1

Hello! I would like to take value typed on the 1st page and present it in a 2nd html page using Javascript. I just get the value to appear on the same page.

   <input type="text" id="cidade"  />                  
   <input type="submit" id="resulCity" onclick="capturar()" value="Buscar">

   <p id="valorDigitado"></p>

    <script>
      var capturando = "";
       function capturar(){
           capturando = document.getElementById('cidade').value;
           document.getElementById('valorDigitado').innerHTML = capturando;  
       }
    </script>
</body>
  • https://answall.com/questions/185897/como-saber-valores-de-teclas-em-javascript/185910?r=SearchResults#185910

  • Fiona, well-see the Stack Overflow in English. Start here to get an overview of the site. https://answall.com/tour

  • You need a page that takes the form from your page above and processes. You can’t do it with two HTML pages.

1 answer

4

  var capturando = "";
   function capturar(){
       capturando = document.getElementById('cidade').value;
       document.getElementById('valorDigitado').innerHTML = capturando;  
       localStorage.setItem('valorDigitado', capturando);
   }

On the other page

var valorDigitado = localStorage.getItem("valorDigitado");

See more in localStorage

Browser other questions tagged

You are not signed in. Login or sign up in order to post.