
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! 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 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 Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 6868)
Tagged: drugstore.com, search engines, web page scripting Previous: How do I create a new MySpace group? Next: Why has my LinkedIn Account been suspended? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.
Rather amazingly, there are no comments on this article yet.
I 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
|