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!
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.