Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

jquery - pass inputbox value as a querystring to 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=

So if Cardiologist is the keyword, it would be like:

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

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...