Hi All
This has probally been asked a thousnad times, but here it goes.
I have built a search bar into my website, and i want the user the be able to enter any text and be able to search google in a new window/tab. This is the code i have so far:

<div id="search">
                <form method="get" target="_new"  action="https://www.google.com/search?q"+document>
                    <input type="text" id="searchtxt" />
                    <input type="submit" name="q" id="searchbtn"/>

The issue i am having is when i type say "test" into the search box and clikc search, i go to google but the word it has searched is submit.

Any help would be great

Recommended Answers

All 3 Replies

Move the name parameter to the input with type="text", then it should probably work!

<input type="text" name="q"id="searchtxt" />
<input type="submit" id="searchbtn"/>

Just to provide you with an additional option that you may have not considered, google has a product called CSE (custom search engine) that you can use to integrate a search feature in your site. If you want to see how it works, use the search feature on DaniWeb. I use it as well on sites that i work on.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.