Reputation: 19
First of all, I can't use the action=''
attribute. That's why I use on submit
.
Here my code:
<form class="search" role="search" method="get" onsubmit="window.location.href='home.php?m=search&q='; return false;">
<input type="text" placeholder="Rechercher..." name="s">
</form>
How can I get my input content after my onsubmit
url ?
Can jQuery could get this content and put it in this address ? How do do this ?
Thanks.
Upvotes: 0
Views: 19
Reputation: 178161
I believe you want
window.location.href='home.php?m=search&q='+this.s.value; return false
Possibly even
window.location.href='home.php?m=search&q='+encodeURIComponent(this.s.value); return false
to be sure
To use the form action, you could do
onsubmit="this.action='home.php?m=search'"
and change name="s" to name="q"
Upvotes: 4