0

I have a simple search form with a single input box. I want the input value to appear in the route URL as a parameter, like:

http://www.website.com/search/{value}

An example might be:

http://www.website.com/search/bob

I also want the route to have an optional value at the end:

http://www.website.com/search/{value}/{optional?}

How can I have the form data be transferred to the route parameter?

Here's the form (nothing special):

<form action="{{ url('/search') }}" method="GET">
    <input class="form-control" name="query" type="text" placeholder="Search">
    <button type="submit" class="btn btn-link">Submit</button>
</form>

I can also use jQuery/Ajax if that helps.

  • May you can use query string paramerter for both . Like http://www.website.com/search?search_parm=bob&optional=temp – vijaykumar Jul 06 '16 at 01:47
  • Will the same page with the form also show the results from the search query? – Ohgodwhy Jul 06 '16 at 02:09
  • If you do not like to write jquery to manually build url, you can do something like this(not recommended)http://stackoverflow.com/a/29433173/3018183 – Ravisha Hesh Jul 06 '16 at 09:49

0 Answers0