Passing queries to google custom search engine
This is how it should work: On every page the user has a search box in the header. When he enters a query there it should be passed to searchresults.html that holds the following javascript code that I got from Google:
<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 : 'de', style : google.loader.themes.V2_DEFAULT});
google.setOnLoadCallback(function() {
var customSearchOptions = {}; var customSearchControl = new google.search.CustomSearchControl(
'001133520264490576315:dwdiy8xzoak', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchResultsOnly();
customSearchControl.draw('cse', options);
function parseParamsFromUrl() {
var params = {};
var parts = window.location.search.substr(1).split('\x26');
for (var i = 0; i < parts.length; i++) {
var keyValuePair = parts[i].split('=');
var key = decodeURIComponent(keyValuePair[0]);
params[key] = keyValuePair[1] ?
decodeURIComponent(keyValuePair[1].replace(/\+/g, ' ')) :
keyValuePair[1];
}
return params;
}
var urlParams = parseParamsFromUrl();
var queryParamName = "q";
if (urlParams[queryParamName]) {
customSearchControl.execute(urlParams[queryParamName]);
}
}, true);
</script>
The search boxes on all the other pages look like this for now:
<form action="search.php" method="post" name="search" id="search">
<img id="imageglass" src="img/search_icon.jpg"/>
<input type="text" name="q" id="searchfield" maxlength="255" value="" />
<input name="imagesearch" type="image" id="imagesearch" src="img/search_go.jpg" alt="submit" />
</form>So the question here is... How do I correctly pass the required string from the search pages to the result page with the google code?
I have tried to find information on this on Google, but didn't find any suitable answer for my setup.
I hope that you guys can help me out here.
Thanks in advance for your support on this.
If it is not clear from my description what is going on, please tell me, I will try to express it differently...
PS. Sorry if this is in the wrong section... the Google code is javascript so I thought I'd put it here...
::::::: E D I T ::::::::
Hmm... So I guess it was because of the form method="post" on the search site...
Changed that to method="get" and it seems to work...
Sorry for that stupid question then.






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None













Help