q= in AJAX API

3 views
Skip to first unread message

Scotty A

unread,
Feb 25, 2009, 1:02:13 PM2/25/09
to Google AJAX APIs
I have created an AJAX API based search using the "searchForm" and
placed this into a DOM object in my CSS based HTML. The search works
fine, but I wanted to create additional search pages, because the
number of CREF AJAX Searchers has grown pretty large, and I wanted to
customize each searcher for an even more specific group of
information. What I am trying to do is edit the code, so I can utilize
an HTML or AJAX statement that will allow me to pass a $q or query
term into the searchForm on another page. I have done something
similar in the past with XML for CSE redirects, but I don't know how
to do this with AJAX.

var options = new google.search.DrawOptions();
options.setSearchFormRoot(document.getElementById
("searchForm"));
var sFormDiv = document.getElementById("searchForm");

<--! in between these statements are the searchers--!>

this.control.draw(sFormDiv);
}

Jeremy Geerdes

unread,
Feb 26, 2009, 12:21:03 PM2/26/09
to Google-AJAX...@googlegroups.com
So, in short, you're wanting to execute the search control on a second
page?

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
jgee...@mchsi.com

Unless otherwise noted, any price quotes contained within this
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!

And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com
!

Scotty A

unread,
Feb 26, 2009, 2:28:12 PM2/26/09
to Google AJAX APIs
Do you know how in CSE XML you can redirect to another CSE, in order
to increase the number of refinements (visible refinements-at least),
with a xml statement with a redirect lable that would look something
like:

"http://www.google.com/cse?cx=....q=$q&amp;safe=active&amp;sa=Search"

This xml code will put the original search term q into the new search
as $q, and when sa=Search, will execute the search inside of the
second cse. Basically the affect I am going for with javascript/ajax/
xhtml

I have done something similar just with a small box on a sharepoint
site (don't get mad at me because its ms:)) with the code that looks
like:

var q = document.getElementById("q");
if(q && q.value.length > 0)
{
var newPage = document.getElementById("newPage");
if(newPage)
{
var url = "http://www.google.com/cse?cref=.....
(urlhere)....xml&amp;safe=active&amp;q=" + q.value;
if(newPage.checked)
window.open(url);
else
document.location.href(url);
}
}
else
{
alert("Please enter one or more search words.");
}
}

how can I the q involved so that it seems to work, but don't know how
to go from sFormDiv to the q version and still make it work. I am
wondering if there is away to right the url statement so that my
search term could entered into the searchform just like with the XML
redirect statement. I have read the RESTful interface documents and
looked at the DOCs, which seam to suggest there is a way to create a
redirect like this and to give the query term a name like q=, so that
a search could be executed by means other than putting text into the
gsc-input.



Also, I have a second (actually its my third) question---http://
groups.google.com/group/Google-AJAX-Search-API/browse_thread/thread/
1b29efbea57c57fa#

On Feb 26, 11:21 am, Jeremy Geerdes <jrgeer...@gmail.com> wrote:
> So, in short, you're wanting to execute the search control on a second  
> page?
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp://jgeerdes.blogspot.comhttp://jgeerdes.wordpress.com
> jgeer...@mchsi.com
>
> Unless otherwise noted, any price quotes contained within this  
> communication are given in US dollars.
>
> If you're in the Des Moines, IA, area, check out Debra Heights  
> Wesleyan Church!
>
> And check out my blog, Adventures in Web Development, athttp://jgeerdes.blogspot.com
>   !
>
> On Feb 25, 2009, at 12:02 PM, Scotty A wrote:
>
>
>
>
>
> > I  have created an AJAX API based search using the "searchForm" and
> > placed this into a DOM object in my CSS based HTML. The search works
> > fine, but I wanted to create additional search pages, because the
> > number of CREF AJAX Searchers has grown pretty large, and I wanted to
> > customize each searcher for an even more specific group of
> > information. What I am trying to do is edit the code, so I can utilize
> > an HTML or AJAX statement that will allow me to pass a $q or query
> > term into the searchForm on another page. I have done something
> > similar in the past with XML for CSE redirects, but I don't know how
> > to do this with AJAX.
>
> > var options = new google.search.DrawOptions();
> >        options.setSearchFormRoot(document.getElementById
> > ("searchForm"));
> >            var sFormDiv = document.getElementById("searchForm");
>
> > <--! in between these statements are the searchers--!>
>
> > this.control.draw(sFormDiv);
> >      }- Hide quoted text -
>
> - Show quoted text -

Jeremy Geerdes

unread,
Feb 26, 2009, 2:33:54 PM2/26/09
to Google-AJAX...@googlegroups.com
Well, the exact method you use is going to vary. If you want a purely
JS method, you should parse the location.href string for the q param.
Alternatively, you could use a server-side script to simply plug the
provided q param into an execute statement.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
Unless otherwise noted, any price quotes contained within this
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!

And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com
!


Reply all
Reply to author
Forward
0 new messages