
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?? 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. Hi Great Post! 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 AMI have a lot to say, but ...
I do have a comment, now that you mention it!
|
![]()
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!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|