Welcome to Dream.In.Code
Become an Expert!

Join 149,513 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,360 people online right now. Registration is fast and FREE... Join Now!




button to search google

 
Reply to this topicStart new topic

button to search google

unsigned user;
13 Jul, 2007 - 03:05 AM
Post #1

New D.I.C Head
*

Joined: 28 Apr, 2007
Posts: 29


My Contributions
Hi,
I'm new to web dev so this might be newbie question. How do I allow the user to press a button (created in HTML) that takes the string entered into the text field and searches google with it? For example, google's search template is http://www.google.ie/search?hl=en&q=QU...UERY2&meta=
I need to replace QUERY1 and QUERY2 with the inputted data. Any ideas or links?
Thanks

User is offlineProfile CardPM
+Quote Post

dogboi
RE: Button To Search Google
14 Jul, 2007 - 02:10 AM
Post #2

D.I.C Head
Group Icon

Joined: 10 Jul, 2007
Posts: 93


Dream Kudos: 25
My Contributions
QUOTE(unsigned user; @ 13 Jul, 2007 - 04:05 AM) *

Hi,
I'm new to web dev so this might be newbie question. How do I allow the user to press a button (created in HTML) that takes the string entered into the text field and searches google with it? For example, google's search template is http://www.google.ie/search?hl=en&q=QU...UERY2&meta=
I need to replace QUERY1 and QUERY2 with the inputted data. Any ideas or links?
Thanks


You're going about it slightly the wrong way, I think. You're trying to grab the text field, and then use it to generate an URL in the form of a google results page.

But you don't have to do it that way. Below is example code that allows you to creates a text box and a submit button, and then searches google.

CODE

<html>
<head>
<title>Google Search</title>
</head>
<body>
    <form action="http://www.google.com/search" name="searchbox"
      method="get">
      <div id="search">
      <input type="hidden" name="hl" value="en" />
      <input type="hidden" name="ie" value="ISO-8859-1" />      
      <input type="text" class="text" maxlength="64" size="40" name="q" value="" />
      <input type="submit" class="submit" value="Search" name="btnG"
        style="font-size:75%;" />
        </div>
    </form>
</body>
</html>


I hope that's what you're looking for
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Button To Search Google
14 Jul, 2007 - 04:34 AM
Post #3

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
looks like it will work to me, but i'm sure if you look around on google, you'd find the code you want, it's usually a copy and paste for free advertisement on google's behalf, lol
User is offlineProfile CardPM
+Quote Post

unsigned user;
RE: Button To Search Google
14 Jul, 2007 - 12:07 PM
Post #4

New D.I.C Head
*

Joined: 28 Apr, 2007
Posts: 29


My Contributions
That's perfect dogboi, thanks! Like I said, I'm new to this web dev thingamajig unsure.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month