これにはいくつかの投稿がありますが、私のケースに適した組み合わせが見つからないようです。jquery を使用して AJAX でフォームを送信します。
<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>
チェックボックスが選択されているテーブル行を選択して削除する必要があります。
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();
}
});
}
});
parents
上記のように試しましclosest
たが、間違った行が削除されます。さらに、チェックボックスで選択できる複数の行ではなく、1 つの行のみを選択しています。