使用cake php和java脚本过滤重复的行(filter duplicate rows with cake php and java script)

编程入门 行业动态 更新时间:2024-10-28 00:22:24
使用cake php和java脚本过滤重复的行(filter duplicate rows with cake php and java script)

我正在尝试过滤使用带有蛋糕php框架工作的java脚本附加的表。 当我点击添加新杂志时,以下代码用于添加此表,但问题是,它添加了之前添加的双行。 所以我需要过滤添加的行来删除重复的行。

/// function to show magazines data table $('#add_researches_button').click(function () { $("input[name='bstock_researchs_id[]']:checked").each(function (i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function (data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function (index, value) { CountResearches++; $("#researches").append("<tr><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });

I'm trying to filter table which is append using java script with cake php frame work . and the following code is for adding this tables when i have click on add new magazine ,, but the problem is that , It's add double rows which has been added before . So i need to filter the added rows to delete the duplicated row.

/// function to show magazines data table $('#add_researches_button').click(function () { $("input[name='bstock_researchs_id[]']:checked").each(function (i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function (data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function (index, value) { CountResearches++; $("#researches").append("<tr><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });

最满意答案

/// function to show magazines data table $('#add_researches_button').click(function() { $("input[name='bstock_researchs_id[]']:checked").each(function(i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function(data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function(index, value) { CountResearches++; if ($("#researches tr[data-id='" + value.research_serial + "']").length == 0) $("#researches").append("<tr data-id='" + value.research_serial + "'><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); }); /// function to show magazines data table $('#add_researches_button').click(function() { $("input[name='bstock_researchs_id[]']:checked").each(function(i) { val[i] = $(this).val(); }); $.ajax({ type: "POST", url: '../BstockIn/getResearchesIds/' + val, dataType: "json", success: function(data) { $('#researches').css('display', 'block'); var res = $.parseJSON(data); var CountResearches = 0; jQuery.each(res, function(index, value) { CountResearches++; if ($("#researches tr[data-id='" + value.research_serial + "']").length == 0) $("#researches").append("<tr data-id='" + value.research_serial + "'><td>" + value.research_serial + "</td><td>" + value.research_release_date + "</td><td>" + value.research_release_hejry_date + "</td><td>" + value.research_pages + "</td><td>" + value.research_copies + "</td></tr>" ); });

更多推荐

本文发布于:2023-08-05 19:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1438088.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   java   php   cake   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!