How to generate a custom URL from a html input?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:07:53

问题


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.


回答1:


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>



回答2:


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



来源:https://stackoverflow.com/questions/13170286/how-to-generate-a-custom-url-from-a-html-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!