"Search Box with multiple targets via dropdown"
Bootstrap 3.3.0 Snippet by filak

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container" id="adv-search"> <form id="nlk-search-form" method="get" action="/" target="_self"> <div class="input-group"> <input input id="nlk-search-str" name="s" type="text" maxlength="200" class="form-control input-lg" placeholder="NLK stránky" required> <div class="input-group-btn"> <div class="btn-group"> <button type="button" class="btn btn-primary btn-lg" id="nlk-search-submit"> <span class="glyphicon glyphicon-search" aria-hidden="true"></span></button> <button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button> <ul class="dropdown-menu nlk-dropdown"> <li><a role="button" class="nlk-search-type" data-value="NLK stránky" data-action="/" data-param="s" data-target="_self">informace o NLK</a></li> <li><a role="button" class="nlk-search-type" data-value="Portál Medvik" data-action="http://www.medvik.cz/bmc/opensearch.do" data-param="q" data-target="_self">dokumenty v knihovnách, české články</a></li> <li><a role="button" class="nlk-search-type" data-value="Summon" data-action="http://nlk.summon.serialssolutions.com/" data-param="q" data-target="_self">online zdroje a plné texty</a></li> </ul> </div> </div> </div> </form> </div>
body { padding: 50px; } .site-title a { display: block; padding-left: 35px; background-image: url(/wp-content/uploads/2016/05/nlk-logo-smaller.gif); background-repeat: no-repeat; background-position: left top; } .carousel-caption { top: 0; bottom: auto; } .carousel .slide-title { font: bold 80px Montserrat, \"Open Sans\", sans-serif; font-size: 80px; } .highlight-title, .call-to-action { display: none; visibility: none; } .excerpt img.size-full { width: auto; } .input-group-btn .btn-group { display: flex !important; } #adv-search { padding: 10px 0 0 0; } #adv-search .nlk-dropdown { left: -150px; } @media screen and (min-width: 768px) { #adv-search { width: 500px; margin: 0 auto; } } #nlk-search-submit { width: 100px; padding-left: 5px; padding-right: 5px; } #nlk-search-str { border-radius: 4px 0 0 4px; min-width: 140px; color: rgb(0,0,0); }
$(document).ready(function(){ $('#nlk-search-str').on('keydown', function(e) { if (e.which == 13 || event.keyCode == 13 ){ $('#nlk-search-submit').trigger('click'); } }); $('#nlk-search-methods').on('keydown', function(e) { if (e.which == 13 || event.keyCode == 13 ){ $('#nlk-search-submit').trigger('click'); } }); $('.nlk-search-type').on('click', function(){ var targetSite = $(this).data('value'); var searchAction = $(this).data('action'); var searchParam = $(this).data('param'); var searchTarget = $(this).data('target'); $('#nlk-search-str').attr('name', searchParam); $('#nlk-search-form').attr('action', searchAction); $('#nlk-search-form').attr('target', searchTarget); $('#nlk-search-str').attr('placeholder',targetSite); }); $('#nlk-search-submit').on('click', function(){ var searchStr = $('#nlk-search-str').val(); if (!searchStr || searchStr == '') { $('#nlk-search-str').attr('placeholder','Zadejte nejdřív dotaz'); } else { $('#nlk-search-form').submit(); } }); });

Related: See More


Questions / Comments: