简体   繁体   English

如何使用多个过滤器过滤搜索结果? (下拉菜单,关键字等)

[英]How can I filter my searchresults with multiple filters? (dropdown, keywords etc)

I have a Codeigniter website with a searchfunction. 我有一个具有搜索功能的Codeigniter网站。 I am able to search on postal code and a keyword. 我可以搜索邮政编码和关键字。 Now I would like to have searchfilters on my 'searchresults' page to narrow the searchresults. 现在,我想在我的“搜索结果”页面上使用searchfilters来缩小搜索结果的范围。

I am using Fastlivefilter jquery plugin now, but I would like to filter on multiple things. 我现在正在使用Fastlivefilter jquery插件,但是我想对多件事进行过滤。

  • A dropdown with categories from my database 我的数据库中带有类别的下拉列表
  • Keywords that I type into the input field. 我在输入字段中键入的关键字。

I got it working with ONLY the dropdown and ONLY the input, but not together. 我只使用下拉菜单和输入,但不能一起使用。

Maybe there's a better way of doing it? 也许有更好的方法呢? Using JQuery Filter() for example? 例如使用JQuery Filter()

My searchform: 我的搜索表:

http://kees.een-site-bouwen.nl/vacatures http://kees.een-site-bouwen.nl/vacatures

How to use: 如何使用:

  • type '9101' into the small input, that says 'postcode'. 在小输入中输入“ 9101”,即“邮政编码”。
  • Submit the form and click on 'searchfilters' now try. 提交表单,然后单击“ searchfilters”,然后尝试。

Here is the simple example i have created for you hope it gives you the idea that you are trying to implement 这是我为您创建的简单示例,希望它给您带来您正在尝试实现的想法

Consider this html that contains the ul li structure with two search fields 考虑包含包含两个搜索字段的ul li结构的此html

<ul>
    <li>bob bope</li>
   <li>bob test</li>
    <li>bob bones</li>
    <li>bob bobs</li>
    <li>test mcBridge</li>
</ul>
<br>
Search: <input id="search" class="search" length="24" />
Refine    <input id="refine" class="search" length="24" />

And here is the jquery which searches as well as refines the results considering the values of both text fields 这是一个jquery ,它考虑到两个文本字段的值来搜索和优化结果

$(document).ready(function(){
    $(".search").keyup(function(){
        $("li").hide();

        if($("#refine").val()!=""){
        var term = $("#search").val()+" "+$("#refine").val();
        }else{
        var term =$("#search").val();

        }
        $("li:contains('" + term + "')").show();

    }); 

});

Try my fiddle for lower case 试试我的小提琴小写

Try my fiddle for upper case 试试我的小提琴大写

I hope this what you were looking for , for testing write bob in first field then write test in other field you will see only one result 我希望这是您想要的,对于测试,在第一个字段中写入bob ,然后在其他字段中写入test ,您只会看到一个结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM