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.
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.
Share Improve this question asked Apr 17, 2011 at 5:26 Carl WeisCarl Weis 7,08215 gold badges65 silver badges86 bronze badges3 Answers
Reset to default 5Simple html:
<html>
<body>
<form action="http://www.google./search" method="get">
<input type="text" name="q">
</form>
</body>
</html>
Try:
var box=document.getElementById('the_search_box');
window.location='http://www.google./search?q='+escape(box.value);
Here's an example on jsfiddle.
You should consider creating a Google Custom Search though.
Checkout the script called LMGTFY (Let Me Google That For You) -- pretty cool implementation.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745403306a4626200.html
评论列表(0条)