1

Possible Duplicate:
pass inputbox value as a querystring to URL

<input name="KeywordBox" class="BasicSearchInputBox" type="text" value="Keywords.."/>
<a class="searchButton" href="/search/pages/Careers.aspx?v=relevance&s=Careers&k=" type="submit">
    <span>Search</span>
</a> 

How do you get the keywords typed in by users and pass it to the page or append to the URL onclick of the 'Search' link?

Like this http://mycompany.com/search/pages/Careers.aspx?v=relevance&s=Careers&k=engineer

Using jquery?

0

2 Answers 2

3

The simplest method is to place your inputs into a form and submit them to your page using the GET method.

If you'd prefer to use jQuery, you can do:

$(function() {
    $(".searchButton").click(function() {
        var keywords = $("#KeywordBox").val();
        window.location.assign("/search/pages/Careers.aspx?v=relevance&s=Careers&k=" + keywords);
    });
});

Just make sure you sanitise your input values properly otherwise you're leaving yourself open to injection attacks.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use the .serialize() method

2 Comments

how do you use it though? I am new to jquery world ??
The hyperlink provides an example as well

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.