There is a search on the site, but I want the written query in the search to be redirected to a specific site.

Code to be changed:

<form class="poick_os" onsubmit="document.getElementById('sfSbm').disabled=true" method="get" action="/search/" > <input class="poick_pole" type="text" name="q" maxlength="30" value="Поиск..." onclick="if (this.value=='Поиск...'){this.value='';}" /> <input class="poick_knopka" type="submit" value="Найти" /> <input type="hidden" name="t" value="0" /> </form> 

And even more difficult - when a user writes a request to the search and clicks to send, a window will pop up, asking him which of the 5 sites to choose in order to find what he has requested.

Closed due to the fact that the question is too common for the participants Alexey Lemesh , Yuri Glushenkov , torokhkun , Mike , Darth Nov 26 Nov '15 at 10:04 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    I'm happy for your "want" and not very happy for inline JS, but what is the question? - Regent Nov.
  • Sorry. For example. The user writes a request on my site in the search for "Superman" and instead of being shown the results of my site, he was thrown onto the site vsemayki.ru/search/ Superman - dilux
  • I understand the essence of your idea, but what did you have a problem with when implementing the idea? - Regent
  • I do not understand how to do) An example is needed - dilux
  • I approximately know how to insert the necessary site into action = "/ search /", but I don’t understand where the postscript comes from after / search / "?" - dilux

1 answer 1

If you open the search results in a separate tab, you can rotate something like this by changing the action form and the name the <input> depending on the selected search engine:

Js:

 $(function() { $('#searcher').on("change", function() { var $selected = $(this).find(':selected'); $('#search').attr('action', $selected.data('domain')); $('#searchValue').attr('name', $selected.data('query')); }).change(); }); 

HTML:

 <form id="search" action="http://google.com/search" target="_blank"> <input id="searchValue" name="q" maxlength="30" placeholder="Поиск..." /> <input type="submit" value="Найти" /> </form> <select id="searcher"> <option data-domain="https://www.google.ru/webhp" data-query="q">Google</option> <option data-domain="https://yandex.ru/search/" data-query="text">Yandex</option> <option data-domain="https://www.bing.com/search" data-query="q">Bing</option> </select> 

Full example in fiddle .

In the case of Google, the search results are not displayed immediately because of the missing parameter in the query #newwindow=1 , but the essence of the idea does not change.

  • @dilux on health. If the answer suits you, you can mark it as accepted by clicking on the checkmark in the upper left of the answer. I hope it can be done in a closed question. - Regent