Select option value - Get from datatable

Asked

Viewed 249 times

0

I would like select option to take the fields from a column in the table

My select:

<div class="dataTables_lenght">
             <label>
               <select id = "select1 " name="select1" aria-controls="example" >
                  <option value="">Existe</option>
                   <option value="">Não Existe</option>

              </select>
              Situação por página
            </label>            

           </div>

My script today.

<script type="text/javascript" charset="utf-8">

    $(document).ready(function() {
    $('#example').DataTable( {          
    "language": {
        "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Portuguese-
           Brasil.json"
    }       
} );}); 
</script>

My code in php

foreach($ArrLog as $linhaDe){

                      for($x=0;$x<count($doc);$x++){
                        $condicaoSection = $doc->field[$x]["source"];
                        $linhaDe["status"] = "not found";
                        if ($condicaoSection == $linhaDe["de"]) {
                            $x = count($doc) + 1;
                            $linhaDe["status"] = "existe";


                        }

                    }
                              echo '<tr>
                              <td>'. $linhaDe["de"] . '</td>;
                              <td>'. $linhaDe["para"] . '</td><td>';

                if ($linhaDe["status"] == "existe"){
                            var_dump($linhaDe); 
                        echo '<span class="badge badge-success">Existe</span>';

                }   
                else
                        echo '<span class="badge badge-danger">Não Existe</span>';
                        echo '</td>

                          </tr>' ;  
                 }

How do I get the value of the variable $linhade that this value appears in the table ,eu tbm put in the select option and change in the table... type a filter any hint??

  • 1

    See these examples: https://datatables.net/examples/api/multi_filter.html, https://datatables.net/reference/api/filter()

  • No, no, no, no. javascript I’m half new yet the information that are populated in this datatable, are picked up through a file txt aew it read and put the table content.. got it??

  • The search box no longer does this when you write something? And why duplicate the filter of how many records will be displayed per page? It’s not very clear what you want.

  • edited the question....

  • 1

    @Ricardomendes Do you want to select (using select 1) the rows of the table according to the state (exists or does not exist)? Or you want to edit the table rows by changing the existing text?

  • @Juven_v yes, I want to select using the select1 type if I select exists ,the table rows only returns me the data that exists, if select Does not exist returns in the table the data that does not exist.

  • My table has the DE - PARA - and SITUATIONSTHE datatable looks like this (https://jsfiddle.net/c261r36x/) The difference is that the data inside the table is data from a txt file that I have separated and placed

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.