We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Вот пытаюсь реализовать поиск по параметрам на своем сайте:)
    пока вот что есть: http://schwalbe.div.net.ua/search

    Столкнулся вот с чем:
    В экселе при одном выбранном параметре в фильтре, в остальных фильтрах в DropDown List отображаются только те значения которые остались в результатах.
    классический случай в Экселе при включенном АВТОФИЛЬТРЕ:)

    Теперь собственно вопрос:
    Как сделать выборку по TV1 где TV2 равно ЗН1
    и при этом вывести список без повторяющихся результатов?

    Просто выборка:
    1
    2
    3
    2
    3
    1
    1
    1

    А требуется:
    1
    2
    3




      http://modx.im - Russian community
      http://extras.evolution-cms.com - Repository for Evolution
    • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
      </head>
      
      <body>
      <script type="text/javascript" 
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">
      $(function(){
        // убираем дубликаты!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        var assigneeMap = {};
        $('#tasks>tbody>tr>td:nth-child(3)').each(function(){
          assigneeMap[$(this).text()] = $(this).text();
        });
       
        var $tooltip = $('<div id="tooltip" />')
          .appendTo('body')
          .hide();
        
        $.each(assigneeMap, function(index, word){
          $('<div class="filter"/>')
            .text(word)
            .appendTo($tooltip)
            .click(function(event){
              $this = $(this);
              filterRows($this.text());
              $tooltip.hide();
            });
        });
      
        $('#tasks>thead>tr>th:nth-child(3)').click(
          function(event) {
            //наведение
            positionTooltip.call(this, event);
          }, 
          function(event) {
            //вывод инфы
          }
        );
        
        var positionTooltip = function(event){
          $tooltip.css({top:event.pageY+20, 
            left:event.pageX, 
            position:'absolute', 
            backgroundColor:'blue'
          }).show();
        };
        
        var filterRows = function(word){
          $('#tasks>tbody>tr')
            .show()
            .find('td:nth-child(3)')
            .not(':contains("'+word+'")')
            .parent()
            .hide();
        };
      });
      
      
      $(function(){
        // убираем дубликаты!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        var assigneeMap = {};
        $('#tasks>tbody>tr>td:nth-child(2)').each(function(){
          assigneeMap[$(this).text()] = $(this).text();
        });
       
        var $tooltip = $('<div id="tooltip" />')
          .appendTo('body')
          .hide();
        
        $.each(assigneeMap, function(index, word){
          $('<div class="filter"/>')
            .text(word)
            .appendTo($tooltip)
            .click(function(event){
              $this = $(this);
              filterRows($this.text());
              $tooltip.hide();
            });
        });
      
        $('#tasks>thead>tr>th:nth-child(2)').click(
          function(event) {
            //наведение
            positionTooltip.call(this, event);
          }, 
          function(event) {
            //вывод инфы
          }
        );
        
        var positionTooltip = function(event){
          $tooltip.css({top:event.pageY+20, 
            left:event.pageX, 
            position:'absolute', 
            backgroundColor:'blue'
          }).show();
        };
        
        var filterRows = function(word){
          $('#tasks>tbody>tr')
            .show()
            .find('td:nth-child(2)')
            .not(':contains("'+word+'")')
            .parent()
            .hide();
        };
      });
      
      
      $(function(){
        // убираем дубликаты!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        var assigneeMap = {};
        $('#tasks>tbody>tr>td:nth-child(1)').each(function(){
          assigneeMap[$(this).text()] = $(this).text();
        });
       
        var $tooltip = $('<div id="tooltip" />')
          .appendTo('body')
          .hide();
        
        $.each(assigneeMap, function(index, word){
          $('<div class="filter"/>')
            .text(word)
            .appendTo($tooltip)
            .click(function(event){
              $this = $(this);
              filterRows($this.text());
              $tooltip.hide();
            });
        });
      
        $('#tasks>thead>tr>th:nth-child(1)').click(
          function(event) {
            //наведение
            positionTooltip.call(this, event);
          }, 
          function(event) {
            //вывод инфы
          }
        );
        
        var positionTooltip = function(event){
          $tooltip.css({top:event.pageY+20, 
            left:event.pageX, 
            position:'absolute', 
            backgroundColor:'blue'
          }).show();
        };
        
        var filterRows = function(word){
          $('#tasks>tbody>tr')
            .show()
            .find('td:nth-child(1)')
            .not(':contains("'+word+'")')
            .parent()
            .hide();
        };
      });
      </script>
      
      
      
      
      
      
      
      <table id="tasks" width="800" border="1">
        <thead>
          <tr>
            <th scope="col" width="250">Фильтр1</th>
            <th scope="col" width="250">Фильтр2</th>
            <th scope="col" >Фильтр3</th>
          </tr>
        <thead>
        <tbody>
          <tr>
            <td>aa</td>
            <td>11</td>
            <td>1</td>
          </tr>
          <tr>
            <td>aa</td>
            <td>22</td>
            <td>2</td>
          </tr>
          <tr>
            <td>bb</td>
            <td>11</td>
            <td>2</td>
          </tr>
          <tr>
            <td>bb</td>
            <td>11</td>
            <td>2</td>
          </tr>
          <tr>
            <td>bb</td>
            <td>33</td>
            <td>1</td>
          </tr>
          <tr>
            <td>cc</td>
            <td>22</td>
            <td>1</td>
          </tr>
          <tr>
            <td>cc</td>
            <td>22</td>
            <td>1</td>
          </tr>
          <tr>
            <td>cc</td>
            <td>33</td>
            <td>2</td>
          </tr>
        </tbody>
      </table>
      </body>
      </html>
      


      может кто знает Jquery и готов немного помочь разобратся?:)
      Нужно проверить выбраны ли какие то фильтры и если выбраны то собрать фильтр из тех позиций что остались:)


        http://modx.im - Russian community
        http://extras.evolution-cms.com - Repository for Evolution
      • Нашел готовый скрипт smiley может ещё кому пригодится smiley
        http://sourceforge.net/projects/xlsheet/

        работает полностью как эксель smiley
        только не кросбраузерно:(
          http://modx.im - Russian community
          http://extras.evolution-cms.com - Repository for Evolution
          • 1611
          • 591 Posts
          пока, то что находится на сайте из первого сообщения работает, но очень тормозит. C2D 6400, Win XP SP3, Firefox 3.5.6
          • Нашел ещё 1 вариант smiley очень зачетный:)
            вот так работает:
            http://schwalbe.div.net.ua/search

            а вот ссылка на их сайт
            http://tablefilter.free.fr/
              http://modx.im - Russian community
              http://extras.evolution-cms.com - Repository for Evolution