将输入框值作为查询字符串传递到URL [英] pass inputbox value as a querystring to URL
本文介绍了将输入框值作为查询字符串传递到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个输入框和一个SEARCH
链接,其样式看起来像搜索"按钮.当用户在输入框中输入关键字时,我想获取该关键字,将其传递,并将其作为搜索查询字符串附加到搜索URL
I have an inputbox and a link for SEARCH
styled to look like a Search button. When a user types in a keyword in the inputbox, I want to grab that keyword, pass it, and append it as a search query string to the search URL
/search/pages/physicians.aspx?v=relevance&s=Physicians&k=
因此,如果Cardiologist
是关键字,它将类似于:
So if Cardiologist
is the keyword, it would be like:
http://ABChospital.org/search/pages/physicians.aspx?v=relevance&s=Physicians&k=Cardiologist
如何在jquery中实现这一目标?
How can I achieve this in jquery?
<input name="KeywordBox" class="BasicSearchInputBox" type="text" value="Enter Keywords.."/>
<div class="searchBtnHolder">
<a class="searchButton" href="/search/pages/physicians.aspx?v=relevance&s=Physicians&k=" type="submit"><span>
Search</span></a>
推荐答案
尝试一下:
$('.searchButton').click(function() {
location.href = this.href + $('.BasicSearchInputBox').val();
return false;
});
这篇关于将输入框值作为查询字符串传递到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文