Advertisement
Kabbalah

JavaScript - Redirecionar input pelo Id usando location.href

Nov 10th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Pegando o valor do input pelo Id e diretionar para uma outra página usando location.href
  2.  
  3. <form>
  4.     <input type="text" id="valor_busca" />
  5.     <input type="submit" value="Pesquisar" onclick="redirecionar()/>
  6. <form/>
  7.                                                    
  8. <script>
  9. function redirecionar() {
  10.    var valor_busca = document.getEementById(" valor_busca").value;
  11.    location.href="site.com/busca/" + valor_busca;
  12. }
  13. <script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement