我有一张发票,当我想编辑时,我希望能够删除一些行,该行要么在数据库中找到,要么已添加,但单击添加按钮。所以我必须根据这个条件删除这一行
下面是我的发票,其中显示行有来自数据库的数据和没有数据的行(添加新的)
所以我已经删除了在 DB 中找到的行,我想按照下面的代码应用第二个条件。
$(document).ready(function () {
$("body").on("click",".remove",function(e){
var last=$('#tdy tr').length;
if(last==1){
alert("you can not remove last row, Otherwise Delete The Order Number!");
}
//here i tried the second condition
else if(iddata=null){
$(this).parent().parent().remove();
}
else{
if(!confirm("Do you really want to delete this?")) {
return false;
}
e.preventDefault();
// var id = $(this).attr('data-id');
var id = $(this).data("id");
var token = $("meta[name='csrf-token']").attr("content");
var url = e.target;
$.ajax(
{
url: "Loading/"+id, //or you can use url: "company/"+id,
type: 'DELETE',
data: {
"id": id,
"_token": token,
},
success: function (response){
if ( data['success'] )
{
alert(data['success']);
location.reload();
}
}
});
return false;
}
});
我该如何解决这个问题,有些人可以帮助我
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句