1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
   | $(document).ready(function(){
 
$('select').niceSelect();
 
      function fetch_data() 
      { 
 
           $.ajax({ 
                url:"select.php", 
                method:"POST", 
                success:function(data){ 
                     $('#live_data').html(data); 
                } 
           }); 
      } 
      fetch_data();
 
 
      $(document).on('click', '#btn_add', function(){
 
           var client = $('#client').text(); 
           var contact = $('#contact').text(); 
           var note = $('#note').text();
           //var status = $('#status').text();
           var status = $('#status').val();
           var id_table = $('#id_table').text();
 
 
           $.ajax({ 
                url:"insert.php", 
                method:"POST", 
                data:{client:client, contact:contact, note:note, status:status, id_table:id_table}, 
                dataType:"text", 
                success:function(data) 
                { 
                     alert(data); 
                     fetch_data(); 
 
                } 
           }) 
      }); 
      function edit_data(id, text, column_name) 
      { 
           $.ajax({ 
                url:"edit.php", 
                method:"POST", 
                data:{id:id, text:text, column_name:column_name}, 
                dataType:"text", 
                success:function(data){ 
                     //alert(data); 
                } 
           }); 
      } 
      $(document).on('keyup', '.client', function(){ 
           var id = $(this).data("id1"); 
           var client = $(this).text(); 
           edit_data(id, client, "client"); 
      }); 
      $(document).on('keyup', '.contact', function(){ 
           var id = $(this).data("id2"); 
           var contact = $(this).text(); 
           edit_data(id,contact, "contact"); 
      });
      $(document).on('keyup', '.note', function(){ 
           var id = $(this).data("id3"); 
           var note = $(this).text(); 
           edit_data(id,note, "note"); 
      });
      $(document).on('change', '.status', function(){ 
           var id = $(this).data("id4"); 
           var status = $(this).val(); 
           edit_data(id,status, "status");
           console.log(status);  
      });
 
      $(document).on('click', '.btn_delete', function(){ 
           var id=$(this).data("id5"); 
           if(confirm("Etes-vous sur de vouloir supprimer cette ligne ?")) 
           { 
                $.ajax({ 
                     url:"delete.php", 
                     method:"POST", 
                     data:{id:id}, 
                     dataType:"text", 
                     success:function(data){ 
                          alert(data); 
                          fetch_data(); 
                     } 
                }); 
           } 
      }); 
 }); | 
Partager