So what I have built is a View of all of my users (thumbnail photos that link to profile). I have set a search filter that searches by keyword and state (location).
What I want to do is get the search results back and then based off of the URL info run the Google custom search (ajax style). This way if the query turns no results then Google will fill it in. It will also look nice to have the list of users and then google results under it.
Right now if I search Mike Smith, Washington my URL is as follows:
...sitename.com/profiles/search?full-sosearch=Mike+Smith&State=Washington
Is there a javascript way to submit a google custom search using the information in that URL once the page is loaded?
The Google Custom Search Box:
<div id="cse-search-form" style="width:350px;">
<form accept-charset="utf-8" class="gsc-search-box" method="get">
<div>
<input type="hidden" name="cx" value="010547798206766551373:reqd2ws7rg8" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input maxlength="128" name="full-sosearch" id="edit-full-sosearch" size="15" value="" title="Enter the terms you wish to search for." class="form-text" type="text">
<input type="submit" name="sa" value="Search" />
</div>
</form>
</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
google.setOnLoadCallback(function(){
var customSearchControl = new google.search.CustomSearchControl('010547798206766551373:reqd2ws7rg8');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setSearchFormRoot('cse-search-form');
customSearchControl.draw('cse', options);
}, true);
</script>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
The Google Search Results Div (for AJAX):
<div id="cse" style="width:100%;"></div>
Any help would be appreciated.
Cheers,
Latte
Comments
I know there is a way to
I know there is a way to split the URL with javascript. But, in thinking about how the views search form is using GET, I should be able to grab the search terms and state from there with PHP.
Once I have the the variables, What next? How would I pass them to the google custom search and run the search via AJAX without the user having to click on a second submit button.
Again, any help would be appreciated.
Cheers,
Latte