Hello,
I'm trying to configure my search form to do a search within my site via google, when they hit the enter button. Right now all my search does is search google.

    <form action="http://www.google.com/search">   
    <input type="text" name="q" onkeypress="submitOnEnter(this, event);"/>   
    </form> 

How can I get it to search my site via google?
Thanks

Recommended Answers

All 2 Replies

I'd recommend that you take a look at the Google Custom Search Engine.
http://www.google.com/cse/

I beleive that this site has this google feature incorporated. On my site, CSE is exactly what i implemented. I basically included an input element on my pages and when a user submits a search, the user is taken to another page on my site where the google results are displayed.

With CSE you have the option of including all search results or just search results from within your domain.

Thanks for your help but I did find a way to do the search via javascript. Here is the code for anyone who is looking:

<script type="text/javascript">

    //Enter domain of site to search.
    var domainroot="www.xxxxxx.com"

    function Gsitesearch(curobj){
    curobj.q.value="site:"+domainroot+" "+curobj.qfront.value
    }

</script>

<form action="http://www.google.com/search" method="get" onSubmit="Gsitesearch(this)">
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" onkeypress="submitOnEnter(this, event);"/>   
</form>
Be a part of the DaniWeb community

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