How can I get the value of an input and after the "submit" redirect to another page with this value in the url?
Ex:
site.com/busca/ BUY VALUE
<form>
<input type="text"/>
<input type="submit" value="Pesquisar"/>
</form>
How can I get the value of an input and after the "submit" redirect to another page with this value in the url?
Ex:
site.com/busca/ BUY VALUE
<form>
<input type="text"/>
<input type="submit" value="Pesquisar"/>
</form>
You can get the value by id
and use location.href
<form>
<input type="text" id="valor_busca"/>
<input type="submit" value="Pesquisar" onclick="redireciona()"/>
</form>
<script>
function redireciona(){
var valor_busca = document.getElementById("valor_busca").value;
location.href="site.com/busca/"+valor_busca;
}
</script>