Industry guru Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, Google AdSense, MySpace, Sony PSP, Apple iPod, Mp3 players, management, Linux, SEO, Mac OS X, Facebook, Twitter, LinkedIn and Microsoft Windows.

How do I build a multi-site search box?

If I have a Google web search form placed in my site, how can I set it up so that there is one input box (for the web search) but two submit buttons - one for a web 'text' search, and one for a google image search? Is that even doable??


Dave's Answer:

That's not terribly difficult to accomplish, actually, and it's quite informative for people seeking to experiment with feeding a search pattern to more than one search engine too.

First off, here's the form at work:


And here's the source for that form, in XHTML:

<form target="_blank" name="googleForm" method="get"
  action="http://www.google.com" style="border:1px solid black;padding:8px;">
<input type="text" name="q" size="40" maxlength="255" value="" /><br />
<input type="submit" value="Google Search!"
  onClick="document.googleForm.action='http://www.google.com/search';" />
<input type="submit" value="Google Images!"
  onClick="document.googleForm.action='http://www.google.com/images';">
</form>

See how that works? All you need to do is change the action value of the form through a tricky little bit of JavaScript.

There's no reason you couldn't use this very same techinque to have a search engine box on your site, for example, that could send the same query to a number of different search engines (though you need to ensure that they all expect the search term to have the same variable name).

Hope this helps!

My thanks to Jason M. Hurst Frye for his help with this snippet of HTML.


Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized: HTML and CSS   (Article 4312)
Tagged:
Previous: How do I split my Typepad entries into two parts?
Next: Can I get Plaxo spam?

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Hi

Great Post!
Is there any way I can get two text boxes as input or 2 drop downs as input and then search the site using the concatenation of the two inputs?

Posted by: Gary at December 6, 2007 7:12 AM

Gary, yes you could: you'd need to stitch them together with some Javascript tied to the "onSubmit" event (you'd add that to the FORM tag). Why do you want to do it that way, though?

Posted by: Dave Taylor at December 6, 2007 10:08 AM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]