我有一个表,其中包含<td>
's 和我从 db 获取数据。我想要的是<td>
在用户删除数据时删除。我是 jquery n js 的新手。当用户想要删除数据时,我使用 bootstrap n 能够显示模式。但我仍然无法删除<td>
哪个用户的删除。我知道代码很乱,对不起我的英语。这是脚本:
foreach ($query as $hasil) {
if($hasil->status_login=='l')
{
$status="Terkunci";
}
else if($hasil->status_login=="n")
{
$status="Non-aktif";
}
else
{
$status="Aktif";
}
echo '<form method="post" action="proses">';
echo '<input type="hidden" name="update_admin"><input type="hidden" name="id" value="'.$hasil->akun_id.'">';
echo '<tr>';
echo '<td>';
echo $hasil->akun_email;
echo '</td><td>';
echo $hasil->akun_tipe;
echo '</td><td>';
echo $hasil->admin_create_date;
echo '</td><td><select name="status"><option>'.$status.'</option><option>Aktif</option><option>Non-aktif</option><option>Terkunci</option><td><a class="btn btn-danger" type="button" data-toggle="modal" href="#myModal'.$i.'" data-backdrop="true">Hapus admin</a></td><td><button type="submit" class="btn btn-primary" href="#">Simpan</button></td>';
echo '</form>';
/**
form buat ngapus
**/
echo '<form id="rm" method="post" action="proses">';
echo '<input type="hidden" name="id" value="'.$hasil->akun_id.'">';
echo '<input type="hidden" name="del" value="true"><input type="hidden" name="lvl" value="admin">';
echo '<div id="myModal'.$i.'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<span><strong>Pesan</strong></span>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Anda yakin ingin menghapus '.$hasil->akun_email.'</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Batal</button>
<button class="btn btn-danger">Hapus saja</button>
</div>
</div>';
echo '<div id="result"></div>';
echo '</form>';
$i++;
}
echo '</table>';
echo "<script>
$('#rm').submit(function() {
var value = $('td').val();
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serializeArray(),
success: function(data) {
$('div[id*=\"myModal\"]').modal('hide');
$('#result').html(data);
$('tr').remove(\":contains(value)\");
}
})
return false;
});";
echo '</script>';
}