user3504260
user3504260

Reputation: 19

$_GET is not passed in this form

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

Answers (1)

mplungjan
mplungjan

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

Related Questions