Reputation: 7072
I have a form with an input control, and a submit button. I would like the user to be able to enter their zip code, and then perform a Google search with what they entered into the input field.
I tried searching online, but couldn't find what I was looking for. I already know the query string format for a Google search, just a little rusty on my HTML and JavaScript.
Upvotes: 0
Views: 4082
Reputation: 2028
Checkout the script called LMGTFY (Let Me Google That For You) -- pretty cool implementation.
Upvotes: 0
Reputation: 10350
Try:
var box=document.getElementById('the_search_box');
window.location='http://www.google.com/search?q='+escape(box.value);
Here's an example on jsfiddle.
You should consider creating a Google Custom Search though.
Upvotes: 1
Reputation: 8530
Simple html:
<html>
<body>
<form action="http://www.google.com/search" method="get">
<input type="text" name="q">
</form>
</body>
</html>
Upvotes: 5