2017-09-28 2 views
0

J'essaye de filtrer la table qui est append en utilisant le script java avec le travail de cadre de gâteau de php. et le code suivant est pour ajouter ces tables quand j'ai cliqué sur ajouter un nouveau magazine ,, mais le problème est que, c'est ajouter des doubles lignes qui a été ajouté avant. J'ai donc besoin de filtrer les lignes ajoutées pour supprimer la ligne dupliquée.filtre dupliquer les lignes avec le script php gâteau et Java

/// function to show magazines data table 
    $('#add_researches_button').click(function() { 
     $("input[name='bstock_researchs_id[]']:checked").each(function (i) { 
      val[i] = $(this).val(); 

     }); 
     $.ajax({ 
      type: "POST", 
      url: '../BstockIn/getResearchesIds/' + val, 
      dataType: "json", 
      success: function (data) { 
       $('#researches').css('display', 'block'); 

       var res = $.parseJSON(data); 

       var CountResearches = 0; 

       jQuery.each(res, function (index, value) { 

        CountResearches++; 

        $("#researches").append("<tr><td>" 
          + value.research_serial + 
          "</td><td>" 
          + value.research_release_date + 
          "</td><td>" 
          + value.research_release_hejry_date + 
          "</td><td>" 
          + value.research_pages + 
          "</td><td>" 
          + value.research_copies + 
          "</td></tr>" 

          ); 


       }); 

Répondre

1
/// function to show magazines data table 
$('#add_researches_button').click(function() { 
     $("input[name='bstock_researchs_id[]']:checked").each(function(i) { 
     val[i] = $(this).val(); 

     }); 
     $.ajax({ 
      type: "POST", 
      url: '../BstockIn/getResearchesIds/' + val, 
      dataType: "json", 
      success: function(data) { 
       $('#researches').css('display', 'block'); 

       var res = $.parseJSON(data); 

       var CountResearches = 0; 

       jQuery.each(res, function(index, value) { 

        CountResearches++; 
        if ($("#researches tr[data-id='" + value.research_serial + "']").length == 0) 
        $("#researches").append("<tr data-id='" + value.research_serial + "'><td>" + 
         value.research_serial + 
         "</td><td>" + 
         value.research_release_date + 
         "</td><td>" + 
         value.research_release_hejry_date + 
         "</td><td>" + 
         value.research_pages + 
         "</td><td>" + 
         value.research_copies + 
         "</td></tr>" 

        ); 


       }); 
+0

Merci, Il travaille !! –