我正在使用add函数生成一个表。我想删除在该表中添加的相同数据。每个表行我设置id但我想检查行数据是否已经在该表中退出时添加。 / p>
function adddata(pos=''){
var main_loc = $("select#drop2 option:selected").attr('value');
var sub_loc = $('#drop3 option:selected').attr('value');
$("#del_row").val();
$.ajax({
url: "add_datas.php",
type: "post",
data: "main_loc="+main_loc+"&sub_loc="+sub_loc,
success: function(result){
$("#tab").show().html(result);
var getDayArray = JSON.parse(result);
var main_name=getDayArray[0][2];
var sub_name=getDayArray[0][3];
var map_label=getDayArray[0][4];
var main_loc_id = $("select#drop2 option:selected").attr('value');
var sub_loc_id = $('#drop3 option:selected').attr('value');
var edit_id = "edit_"+main_loc_id+"_"+sub_loc_id;
if(pos!="") {
var table = document.getElementById("tab_grid");
var row = table.insertRow(pos);
row.id = edit_id;
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = main_loc_id;
cell2.innerHTML = sub_loc_id;
cell3.innerHTML = main_name;
cell4.innerHTML = sub_name;
} else {
$('<tr id = "'+edit_id+'"><td>'+main_loc_id+'</td><td>'+sub_loc_id+'</td><td>'+main_name+'</td><td>'+sub_name+'</td><td>'+map_label+'</td><td>'+first_level+'</td><td>'+second_level+'</td></tr></table>').appendTo('#tab_grid');
}
}
});
}