-1

As the title states, I'm trying to incorporate many searches into one search bar. More specifically, Google and Amazon. I have setup a radio option to set which site to search when one is selected. This is the code I currently have:

<form method="get" action="http://www.google.com/search">

    <div align="center" style="font-size:75%">
        <input type="text"   name="q" size="25" maxlength="255" value="" />
        <input type="submit" value="Google or Amazon Search" /></br>
        <input type="radio"  name="sitesearch" value="" />The Web
        <input type="radio"  name="sitesearch" value="yoursite.com" checked />This Site
    </div>
   </form>

I have this form for Amazon, but I'm just unsure how to code it into the one search bar.

<form action="http://amazon.com/s/ref=nb_sb_noss" method="get" target="_blank">
    <input type="text" id="twotabsearchtextbox" name="field-keywords">
    <input type="submit" value="Search" class="nav-submit-input">
</form>
  • You can perform multiple searches via AJAX ( by posting to google, getting the results, posting to amazon, getting the results, and doing something based on those results ). – John Apr 06 '14 at 23:25

1 Answers1

0

Use JavaScript to change the actual form action in page's DOM (and other parameters, if needed), depending on the user selection (use onclick event on radio to montior for change for example). Simple as that. You won't be able to do that in pure HTML without using some kind of proxy server to redirect the requests and return the results appropriately.

document.your-form.action = (google_selected) ? "http://www.google.com/search" : "http://amazon.com/s/ref=nb_sb_noss";

etc.