Pass variable to Google Custom Search Engine

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-02-19T16:47:58Z Indexed on 2010/06/13 6:22 UTC
Read the original article Hit count: 289

Filed under:
|

Is it possible to pass a search variable into the Google Custom Search Engine that I have embedded on my website? I can get the search engine to work, but I can't pass it a term via POST (it's coming from a search button on other pages of the website)

I tried to hack the code I found here: http://code.google.com/apis/ajax/playground/?exp=search#hello_world

And this is what I have so far... ($q is the term I am passing to it)

<script type="text/javascript">
    google.load('search', '1', {language : 'en'});

    function OnLoad()
    {
        var customSearchControl = new google.search.CustomSearchControl('***my key****');
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
        searchControl.execute("$q");
    }
    google.setOnLoadCallback(OnLoad);
</script>   

Thanks

© Stack Overflow or respective owner

Related posts about search-engine

Related posts about google-cse