I have html table which displays columns-client name, staff name and matter whereas in my database i have id,date,client_name,staff,matter columns. well that's not the problem. i wanted to delete the rows on button click so i just added a column delete which contains button with id-"del", and yes this column does not exist in my database. now I want to delete the rows from my table as well as database on the corresponding button click using Jquery. how do I do that? This is what I have tried so far-
$(document).ready(function(){
$('#tableresult').on('click', '#del', (function(){
var row = $(this).attr('id');
$(#tableresult).removeRow(row);
});
});
n my html-
<td class="delete_td"><button id="del" btn btn-danger>×</button></td>
this is my html table code-
<table class="footable" data-filter="#filter" id="tableresult">
<thead>
<th>Client name</th>
<th>Staff name</th>
<th>Matter</th>
<th> Delete</th>
</thead>
<?php
include('db.php');
$sql=mysql_query("select * from newdata");
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$clientname=$row['client_name'];
$staff=$row['staff'];
$matter=$row['matter'];
?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<td class="edit_td" >
<span id="client_<?php echo $id; ?>" class="text"><?php echo $clientname; ?></span>
<input type="text" value="<?php echo $clientname; ?>" class="editbox" id="client_input_<?php echo $id; ?>" />
</td>
<td class="edit_td">
<span id="staff_<?php echo $id; ?>" class="text"><?php echo $staff; ?></span>
<input type="text" value="<?php echo $staff; ?>" class="editbox" id="staff_input_<?php echo $id; ?>"/>
</td>
<td class="edit_td">
<span id="matter_<?php echo $id; ?>" class="text"><?php echo $matter; ?></span>
<input type="text" value="<?php echo $matter; ?>" class="editbox" id="matter_input_<?php echo $id; ?>"/>
</td>
<td class="delete_td"><button id="del" btn btn-danger>×</button></td>
</tr>
<?php
}
?>
</tbody>
<tfoot class="hide-if-no-paging">
<th> </th>
<th>
<div class="pagination pagination-centered"></div>
</th>
<th> </th>
<th> </th>
</tfoot>
</table>
this is my table_edit.js code-see if this has any relevance
$(document).ready(function()
{
$(".edit_tr").click(function()
{
var ID=$(this).attr('id');
$("#client_"+ID).hide();
$("#staff_"+ID).hide();
$("#matter_"+ID).hide();
$("#client_input_"+ID).show();
$("#staff_input_"+ID).show();
$("#matter_input_"+ID).show();
}).change(function()
{
var ID=$(this).attr('id');
var client=$("#client_input_"+ID).val();
var staff=$("#staff_input_"+ID).val();
var matter=$("#matter_input_"+ID).val();
var dataString = 'id='+ ID +'&clientname='+client+'&staff='+staff+'&matter='+matter;
//$("#client_"+ID).html('<img src="load.gif" />'); // Loading image
if(client.length>0 && staff.length>0 && matter.length>0)
{
$.ajax({
type: "POST",
url: "table_edit_ajax.php",
data: dataString,
cache: false,
success: function(html)
{
$("#client_"+ID).html(client);
$("#staff_"+ID).html(staff);
$("#matter_"+ID).html(matter);
}
});
}
else
{
alert('enter something');
}
});
// Edit input box click action
$(".editbox").mouseup(function()
{
return false
});
// Outside click action
$(document).mouseup(function()
{
$(".editbox").hide();
$(".text").show();
});
});