Adding then deleting a row from a table javascript and php

i am new to web programming, i am stock in a litle problem, i have a table with in the last column 2 buttons edit and delete and belew the table a serie of inputs who adds rows to this table, so it works perfectly except when i add a new row then i am tring to delete it, it doesnt delete it, because it dont take the new id from it, Unlike the other rows, please i am desperate. here is my code for add and delete function and the select.

 function postajout(){
	    var _id = $('input[name="idrow"]').val();// here i dont know what to put !
	    var _type = $('#typeid').val();
		var _pression = $('#pressionid').val();
		var _code = $('input[name="code"]').val();
		var _designiation = $('input[name="designiation"]').val();
		var _diametre = $('input[name="diametre"]').val();
		var _epaisseur = $('input[name="epaisseur"]').val();
		var _prix = $('input[name="prix"]').val();
		var _etat = $('input[name="etat"]').val();

//pour ne pas avoir de multiple tables 

		$.post('validate.php', {postid:_id, posttype:_type, postpression:_pression, postcode:_code, postdesigniation:_designiation, postdiametre:_diametre, postepaisseur:_epaisseur, postprix:_prix, postetat:_etat}, 
              function(data){
                
              $('.table').html(data);

             
		   var _tr = '<tr><td>'+ _code +'</td> <td>'+ _designiation +'</td> <td>'+_diametre+'</td> <td>'+_epaisseur+'</td> <td>'+_prix+'</td> <td>'+_etat+'</td> <td><button type="button" onclick="postedit();" class="btn btn-success btn-edit">Modifier </button> | <button type="button" onclick="pdelete('+_id+');" class="btn btn-danger btn-delete">Supprimer </button></td></tr>';
		              
		              $('tbody').append(_tr);
		              
       });

function pdelete(postid){
	  // var _id = postid;
   	    //var _id = $('input[name="idrow"]').val();
   	    var _id=$row['postid'];
	    var _type = $('#typeid').val();
		var _pression = $('#pressionid').val();   
		var _code = $('input[name="code"]').val();
		var _designiation = $('input[name="designiation"]').val();
		var _diametre = $('input[name="diametre"]').val();
		var _epaisseur = $('input[name="epaisseur"]').val();
		var _prix = $('input[name="prix"]').val();
		var _etat = $('input[name="etat"]').val();

	$.post('delete.php', {postid:_id, posttype:_type, postpression:_pression, postcode:_code, postdesigniation:_designiation, postdiametre:_diametre, postepaisseur:_epaisseur, postprix:_prix, postetat:_etat}, 
              function(data){
        		
		$('tbody').append(data);
              });
}

and the select table is like this

 while($row = mysqli_fetch_array($result))
     { 
     ?>
     <tr>
      <td><?php echo $row['code'] ;?></td>
      <td><?php echo $row['designiation'] ;?></td>
      <td><?php echo $row['diametre'] ;?></td>
      <td><?php echo $row['epaisseur'] ;?></td>
      <td><?php echo $row['prix'] ;?></td>
      <td><?php echo $row['etat'] ;?></td>
      <td style="display:none;"><?php echo $row['id'] ;?></td><!--style="display:none;"-->

     <td><button type="button" class="btn btn-success btn-edit">Modifier     </button> | 
      <button type="button" onclick="pdelete(<?php echo $row['id']; ?> );" class="btn btn-danger btn-delete">Supprimer  </button>
  </td>

     </tr>

how do i proceed please

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.