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.

Limit my Amazon searches to only books?

I have a search box on my Web site that I got from the Amazon Associates program and it's a nice addition to the site, except that I really want people to only have results from their books department, not all across the Amazon system. Is that possible?


Dave's Answer:

The Amazon Associates program is one of the unsung heroes of the net, actually, both from the perspective of webmasters who have earned a pretty penny through it and from Amazon itself, who makes a surprisingly large percentage of its gross revenue from Associate sales. I'm a member too.

What you're asking involves basically reverse engineering a complex form that Amazon offers in its associates area. Start by having a look at their search with dropdown menu snippet, because that offers the functionality you want, it just doesn't hide the actual category selector.

Here's how that form looks:

Of course, Amazon's doing this with an iframe, but if you dig into the source itself (try "View Source" on this page, for example), you'll find that there's a block of code that looks like:

<select name="index">
<option value="blended">All Products</option>
<option value="apparel-index">Apparel & Accessories</option>
<option value="baby">Baby</option>
<option value="beauty-index">Beauty</option>
<option value="books">Books</option>
<option value="photo">Camera & Photo</option>
etc. etc.

That's the key, the variable index. To automatically have books be preselected as the search category, and to hide that selection from the user, simply use:

<input type="hidden" name="index" value="books" />

Put that all together and here's a search box that only gives you results in the books category at Amazon.com:

<form action="http://www.amazon.com/gp/associates/link-types/searchbox.html"
method="get" name="search" target="_top">
<input type="hidden" name="tag" value="davetaylor" />
<input type="hidden" name="mode" value="books" />
Search Amazon for:
<input id="keyword" name="keyword" type="text" size="18" />
<input type="submit" value="Go!" />
</form>

In use, this minimalist form looks like:

Search Amazon for:

That should get you going with your HTML task. Good luck!



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 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

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 - 2009 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.