There are several posts on this but I can't seem to find the right combination for my case. I submit a form with AJAX using jquery:
<form id="deleteform" name="myform" action="">
<table id="webcam-table">
<thead>
<tr>
<th>Name</th>
<th>...</th>
<th><input type="checkbox" name="checkboxselectall" title="Select All" />
<button type="submit" class="deletebutton" name="delete_video" title="Delete the selected videos">Delete</button></th>
</tr>
</thead>
<tbody>
<tr >
<td>some data</td>
...
<td><input type="checkbox" value="<?php echo $this->result_videos[$i]["video_name"]; ?>" title="Mark this video for deletion"/></td>
</tr>
</tbody>
</table>
</form>
I need to select the table row where a checkbox has been selected and remove that.
var checked = jQuery('input:checkbox:checked').map(function () {
return this.value;
}).get();
var $this = jQuery(this);
jQuery.ajax({
type: 'POST',
url: 'index.php?option=com_recordings&task=deletevideos&format=raw',
data: {checkedarray:checked},
success: function(data){
jQuery('#deleteform input:checkbox').each(function(){
if(this.checked){
$this.parents("tr").remove();
}
});
}
});
I've tried parents as above and closest but that removes the wrong row. Plus it's only selecting the one row instead of the multiple rows that may be selected with a checkbox.