Reputation: 392
I have a simple form with method="get"
and action="?subject=search_result&"
:
<form class="form" id="searchform" name="searchform" action="?subject=search_result&" method="get">
<input type="text" name="search" class="form-control" placeholder="Search for...">
<button class="btn btn-default" type="submit">Go!</button>
</form>
it only return
?search=blablabla
instead of
?subject=search_result&search=blablabla
Upvotes: 1
Views: 188
Reputation: 339
You can use the hidden input field to set the extra parameters and you can remove the action attribute. The default method is GET, that can also be avoided as shown below:-
<form class="form" id="searchform" name="searchform">
<input type="hidden" name="subject" value="search_result">
<input type="text" name="search" class="form-control" placeholder="Search for...">
<button class="btn btn-default" type="submit">Go!</button>
</form>
Upvotes: 1
Reputation: 17333
You can just do this:
<form class="form" id="searchform" name="searchform" action="" method="get">
<input type="text" name="search" class="form-control" placeholder="Search for...">
<button class="btn btn-default" type="submit">Go!</button>
<input type="hidden" name="subject" value="search_result">
</form>
Notice the <input type="hidden"
. This will give you both search
and search_result
inside your URL.
Upvotes: 1