[英]search box - only first option works
I have a search box with an option to 'search catalog' and 'search site', which go to different urls. 我有一个搜索框,其中包含“搜索目录”和“搜索站点”的选项,它们会转到不同的URL。 I can only get the 'search catalog' option to work. 我只能使“搜索目录”选项起作用。 'Search site' just goes to the same catalog url rather than to the homepage. “搜索站点”只是转到相同的目录URL,而不是首页。 I think there is an issue with the onchange, but I really don't know what I'm doing so I'd appreciate any help. 我认为onchange存在问题,但是我真的不知道自己在做什么,因此我将不胜感激。 Thank you! 谢谢!
<!-- search -->
<div id="search">
<a href="#" class="searchBtn"><span class="icon-search icon-white"></span></a>
<div class="search">
<form id="searchform" action="http://wilkinson.opac.marmot.org/Union/Search/" method="get">
<select style="width: 150px; background: none;" onchange="if(this.value == 1){jQuery('#searchform').attr('action','http://wilkinson.opac.marmot.org/Union/Search?searchsource=local/'); }else{ jQuery('#searchform').attr('action', '<?php echo home_url(); ?>'); }">
<option value="1">Search Catalog</option>
<option value="2">Search Site</option>
</select>
<input name="lookfor" maxlength="20" class="inputbox" type="text" size="20" value="<?php echo __( 'SEARCH ...', THEMENAME );?>" onblur="if (this.value=='') this.value='<?php echo __( 'SEARCH ...', THEMENAME );?>';" onfocus="if (this.value=='<?php echo __( 'SEARCH ...', THEMENAME );?>') this.value='';" />
<input type="submit" id="searchsubmit" value="go" class="icon-search"/>
</form>
</div>
</div>
<!-- end search -->
Your redirect code is working just fine, you just need to have a page that can actually return search results. 您的重定向代码工作正常,您只需要有一个可以实际返回搜索结果的页面即可。 What I've done on other sites is to use Google's search api. 我在其他网站上所做的就是使用Google的搜索API。 Since you're a public library, you can actually get them for free. 由于您是公共图书馆,因此实际上您可以免费获得它们。 Take a look at Google's custom search: https://support.google.com/customsearch/answer/72325?hl=en 看一下Google的自定义搜索: https : //support.google.com/customsearch/answer/72325?hl=zh_CN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.