Results 1 to 6 of 6

Thread: Changing <form> search option from dropdown?

  1. #1
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing <form> search option from dropdown?

    Hi, I'm trying to set up a custom google search where users can select from a dropdown the particular site they want to search within - I've got it working great using the google option:

    <input type="hidden" name="as_sitesearch" value="http://www.duck.com">

    where the value would only return results within the site duck.com site.

    However I'd like to have this as a variable where the user can select from a dropdown which site and the value is taken from their option in this form - I've had a go below - it looks fine, but doesn't appear to work at all!

    Can someone give me a pointer or two? I thought by using 'sections' as a value and then putting it in the dropdown would work, but it didn't (I was feeling optimistic!)

    <form method="get" action="http://search.rbsgrp.net/search" id="googleSearch">
    <input type="hidden" name="access" value="p">
    <input type="hidden" name="output" value="xml_no_dtd">
    <input type="hidden" name="site" value="default_collection">
    <input type="hidden" name="ie" value="UTF-8">
    <input type="hidden" name="client" value="default_frontend">
    <input type="hidden" name="oe" value="UTF-8">
    <input type="hidden"
    name="proxystylesheet" value="default_frontend">
    <input type="hidden" name="as_dt" value="i">
    <input type="text" name="as_lq" size="50" value="sections">
    <SELECT NAME="sections" size="1">
    <OPTION value="http://www.home.com">Home server</OPTION>
    <OPTION value="http://www.retail.com">Retail</OPTION>
    </SELECT>
    <input type="hidden" name="as_sitesearch" value="sections">
    <input value="Go" type="submit" class="gobutton" />
    <img src="images/searchedby_home.gif" alt="Powered by Google" />
    </form>

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by divtag33
    Hi, I'm trying to set up a custom google search where users can select from a dropdown the particular site they want to search within - I've got it working great using the google option:

    <input type="hidden" name="as_sitesearch" value="http://www.duck.com">

    where the value would only return results within the site duck.com site.
    Then give the select element the same name attribute value:

    HTML Code:
    <select name="as_sitesearch" size="1">
        <option value="http://www.duck.com">Duck.com</option>
        <option value="http://www.example.com">Example.com</option>
    </select>
    By the way, are you certain that the scheme (http: ) and authority prefix (//) are necessary? I would have thought that only the host name (www.duck.com) would be.

    Mike

  3. #3
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hmm doesn't appear to be working unfortunately - according to google's docs:

    http://code.google.com/enterprise/do...reference.html

    the 'as_sitesearch' should limit results to whatever is specified as its value
    so whereas I had:

    <input type="hidden" name="as_sitesearch" value="www.bbc.co.uk">

    And it worked great showing only results from the bbc site - when I swap it for:

    <SELECT NAME="as_sitesearch" size="1">
    <OPTION value="http://www.home.com">Home server</OPTION>
    <OPTION value="http://www.retail.com">Retail</OPTION>
    </SELECT>

    It doesn't return the results...

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by divtag33
    ... I had:

    <input type="hidden" name="as_sitesearch" value="www.bbc.co.uk">

    And it worked great showing only results from the bbc site - when I swap it for:

    <SELECT NAME="as_sitesearch" size="1">
    <OPTION value="http://www.home.com">Home server</OPTION>
    <OPTION value="http://www.retail.com">Retail</OPTION>
    </SELECT>

    It doesn't return the results...
    You might want to compare how the values in the quote above differ from each other, and then re-read the last sentence in my previous post.

    In other words, see if:

    HTML Code:
    <select name="as_sitesearch" size="1">
      <option value="www.home.com">Home server</option>
      <option value="www.retail.com">Retail</option>
    </select>
    is any better (it certainly should be).

    Mike

  5. #5
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes you're quite right - that's got it almost working now - what I'm needing is to be able to search selected pages for links - so a manual google search would be something like:

    link: www.sport.com site:www.bbc.co.uk

    This would give me all links to sport.com within bbc.co.uk pages.

    Now I've tried to get them both inputted below, but I can't figure out how to tell it to include both. It seems to include one or the other. The below code is giving me a resulting search of link:www.thesiteienter.com but it isn't limiting it to certain sites as selected in the dropdown.

    If I change:

    <input type="text" name="as_lq" id="googleQueryText" maxlength="256" title="Google Search Text" />

    back to:

    <input type="text" name="q" id="googleQueryText" maxlength="256" title="Google Search Text" />

    It'll work looking for keywords within the sites selected:

    the two google commands are as_lq for the link searches and as_sitesearch to search within a site - is there a way to put both of these into the above form name? as_lq+as_sitesearch or something?!?

    Many thanks!

    <form method="get" action="http://search.grp.net/search" id="googleSearch">
    <input type="hidden" name="access" value="p">
    <input type="hidden" name="output" value="xml_no_dtd"><input type="hidden" name="site"

    value="default_collection">
    <input type="hidden" name="ie" value="UTF-8">
    <input type="hidden" name="client" value="default_frontend">
    <input type="hidden" name="oe" value="UTF-8">
    <input type="hidden" name="proxystylesheet" value="default_frontend">
    <input type="hidden" name="as_dt" value="i">
    <input type="text" name="as_lq" id="googleQueryText" maxlength="256" title="Google Search Text" /> <select

    name="as_sitesearch" size="1">
    <option value="http://www.test.net">Home</option>
    <option value="http://www.retail.net/gfk">test2</option>
    </select><input value="Go" type="submit" class="gobutton" />
    <img src="images/searchedby_home.gif"
    alt="Powered by Google" />
    </form>

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by divtag33
    the two google commands are as_lq for the link searches and as_sitesearch to search within a site - is there a way to put both of these into the above form name? as_lq+as_sitesearch or something?!?
    There doesn't appear to be. In the documentation you cited earlier, it states for as_lq that "no other query terms can be used when using this parameter". See the table in section 2.2 Search Parameters.

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •