Reputation: 705
<form action="includes/search.php" method="get">
<input name="search" type="text" class="search" />
<input type="submit" value="Search" />
</form>
I want user to type text in textfield and when he hits enter it will paste it in URL.
Currently url is: http://randomsite.com/includes/search.php?search=adsasd
But it should be like this: http://randomsite.com/beta/match/adsasd
Upvotes: 0
Views: 555
Reputation: 508
You are currently submitting the form as a GET request to the includes/search.php page.
Try calling a JavaScript function instead:
<form id="search-form" onsubmit="return performSearch()">
<input name="search" type="text" class="search" id="search-query" />
<input type="submit" value="Search" />
</form>
Then collect the information from each field, and redirect to the desired URL in that function:
function makeSearch()
{
var searchQuery = document.getElementById("search-query").value;
var searchURL = 'http://randomsite.com/beta/match/' + searchQuery;
window.location.assign(searchURL);
return false;
}
NOTE: Untested, but should work or be very close to a solution.
Upvotes: 2