Reputation: 61773
I have a google site search
http://www.google.com/cse/manage/create
Which gives me the following working code:
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', { language: 'en' });
google.setOnLoadCallback(function () {
var customSearchControl = new google.search.CustomSearchControl('013080392637799242034:ichqh_hal4w');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
}, true);
</script>
On some of my pages, I have a search box. Can I make the text entered in that search box, post to this site search script and load?
For example:
At the moment I have:
// Temporary measure
SearchBox.click(function (event) {
SearchBox.attr('disabled', 'disabled');
SearchBox.css("background", "#efefef");
window.location.replace(Domainroot + "/search");
});
Which is less than ideal, but works OK. When a user clicks the search box it redirects them to the search page to save them double entering the query.
Thanks for any help!
Upvotes: 3
Views: 709
Reputation: 3373
Have a look at http://code.google.com/apis/customsearch/docs/js/cselement-reference.html#_methods-el
It looks like the control you create comes with methods. It seems you are looking for the .execute(query) method.
Upvotes: 1
Reputation: 1289
One way is to have the iFrame code right on you homepage and you can customize it. You will find various ways to do it. But if you want to a more personalized thing like have a search box and then have results in your page then I would suggest you do a backend process to querying Google and then post back the results. Check Nokogiri example for what I mean.
Upvotes: 0