I have a webpage that shows data as followed:
| id | name | delete |
| 1 | orange | delete |
| 2 | apple | delete | etc...
When you press delete (its a button) you get a jquery dialog showing again two buttons. You can delete multiple items at once or only the selected item.
-------------------------------
|dialog |
-------------------------------
|delete this row |
|delete entire series |
-------------------------------
My question is: When for example 'delete this row' is selected in the dialogbox, how do I get the ID of the selected row in jquery? How can I redirect to a php page that deletes the row in the db and then redirect to the current updated page (with the row removed)?
I'm very new to jquery, but this is what I got so far:
JQuery
<script>
$(function() {
$( ".dialog" ).dialog({ autoOpen: false });
});
$(function() {
$(".showDialog").click( function()
{
$( ".dialog" ).dialog( "open");
});
});
$(function() {
$( ".deleteEvent" ).click( function()
{
$( ".dialog" ).dialog( "close");
$(this).closest("tr").remove(); // doesn't work
});
});
</script>
Dialog
<div class="dialog" title="delete event dialog">
<input class="deleteEvent" type='button' value='delete this row'/>
</div>
Table
foreach($table as $row)
{
echo '<tr><td>'.$row['id'].'</td>',
'<td>'.$row['name'].'</td>',
'<td><div class="showDialog" ><IMG style="margin-left:15px;" src="./public/pictures/trash.gif"></a></div></td>',
'</tr>';
}