简体   繁体   中英

How to generate a custom URL from a html input?

I want to create a search bar which takes in a query and adds the rest of the URL then goes to the site. For example

Input: walmart
Output: http://www.example.com/?t=w&p=0&q= walmart

then the program navigates to the link that is generated. This is like how Google Chrome's omnibox works.

just simple html form

<form method="GET" action="http://www.example.com/">
   <input type="text" name="q">
   <input type="hidden"  name="t" value="w">
   <input type="hidden"  name="p" value="0">
</form>

Here's something I made for my site:

trapper.site90.net/luckysearch

You may use my code if you want. I tested it. Just use inspect element on my page. :D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM