Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How do I add a Drugstore.com search to my Web site?

I really like the Google search box you demonstrate on this site, but I want to add a search box on my site for Drugstore.com, and can't figure out how to do it. I thought I had it all working, but it's not. Can you help me out? I'll be forever in your debt!


Dave's Answer:

Forever's a long time, but let's have a stab at reverse engineering the Drugstore.com search that's on its site and trimming it down to its essentials.

The first step is to do a "View Source" (usually View --> View Source). In that huge tangle of code we find:

<form name="FRM_SEARCH" method="get" action="/search/search.asp" style="margin:0;padding:0;"><input type="hidden" name="searchtype" value="1"><input type="hidden" name="trx" value="28198"><input type="hidden" name="trxp1" value="60"><input type="hidden" name="ipp" value="20"><input type="hidden" name="srchtree" value="1"><input class="xsmall" type="text" size=24 maxlength=50 name="search" value="" style="height:19px;"></td><td valign="middle" style="border-bottom:1px solid #999999;padding-left:2;"><input name="Go" type="image" src="http://a1624.g.akamai.net/.../nav_go_button.gif" vspace=0 hspace=5 alt="Go" border=0></form>

Ugh, ugh. As a first step, I'll go ahead and add returns so we can see what's what:

<form name="FRM_SEARCH" method="get" action="/search/search.asp"
 style="margin:0;padding:0;">
<input type="hidden" name="searchtype" value="1">
<input type="hidden" name="trx" value="28198">
<input type="hidden" name="trxp1" value="60">
<input type="hidden" name="ipp" value="20">
<input type="hidden" name="srchtree" value="1">
<input class="xsmall" type="text" size=24 maxlength=50 name="search"
value="" style="height:19px;">
</td>
<td valign="middle" style="border-bottom:1px solid #999999;padding-left:2;">
<input name="Go" type="image"
 src="http://a1624.g.akamai.net/.../nav_go_button.gif"
 vspace=0 hspace=5 alt="Go" border=0>
</form>

It sure looks to me like we can dump some of these variables, and we can certainly lose the formatting table tags "td" and convert the img submit into a regular submit button, for simplicity sake. Also note the form value action: you need to normalize that to point to the Drugstore.com server, so I'll do that too.

A little bit of experimentation reveals that all of the hidden variables are unnecessary (I simply added an 'x' before the word input on each of them in my test file, so they looked like <xinput type=... and found that the form still worked just dandy from my austere test page) so here's my minimalist Drugstore.com search box:

<form method="get" action="http://www.drugstore.com/search/search.asp">
  Search Drugstore.com:
  <input type="text" size=24 name="search" />
  <input type="submit" value="Go" />
</form>

Now you can go back and add fancy formatting and styles if you'd like, but the raw search should work just fine exactly as shown above. Here, test it:

Search Drugstore.com:

Search for, oh, I dunno, "vitamins" or "combs" to see how it works out.



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

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

Comments
Rather amazingly, there are no comments on this article yet.

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

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.








Ask Dave Taylor: The iPhone App: Advertisement


Uniblue: Get A Free Virus Scan!

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ 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
Book Links
© 2002 - 2010 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]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.