2011-12-05 31 views
0

我有一個輸入框和一個SEARCH的鏈接,看起來像一個搜索按鈕。當在輸入框的關鍵詞,用戶類型,我想抓住這個關鍵詞,通過它,並追加其作爲搜索查詢字符串搜索網址將輸入框值作爲查詢字符串傳遞到URL

/search/pages/physicians.aspx?v=relevance&s=Physicians&k= 

所以,如果Cardiologist是關鍵字,這將是像:

http://ABChospital.org/search/pages/physicians.aspx?v=relevance&s=Physicians&k=Cardiologist 

我該如何在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> 
+1

你爲什麼不只是使用''

用''按鈕?對於這個簡單的HTML任務,jQuery真的需要嗎? – BalusC

回答

0

試試這個:

$('.searchButton').click(function() { 
    location.href = this.href + $('.BasicSearchInputBox').val(); 
    return false; 
}); 
相關問題