Javascript 已删除的数据仍会提示“已存在”
我有两个发送数据的过程。第一个是表格,第二个是文本框。“table_select”是我检索数据的地方,“attendee_table”是我在保存流程之前临时发送数据的地方。提交时,它会保存到数据库中 问题是,当我检查重复条目时,它运行良好。但是当我删除其中一个条目时,它仍然提示该条目存在注意:它尚未保存在数据库中。 但当我将其保存到数据库时,删除的条目不包括在数据库中。这是什么意思 以下是我的Jquery/Javascript代码:Javascript 已删除的数据仍会提示“已存在”,javascript,jquery,arrays,html-table,Javascript,Jquery,Arrays,Html Table,我有两个发送数据的过程。第一个是表格,第二个是文本框。“table_select”是我检索数据的地方,“attendee_table”是我在保存流程之前临时发送数据的地方。提交时,它会保存到数据库中 问题是,当我检查重复条目时,它运行良好。但是当我删除其中一个条目时,它仍然提示该条目存在注意:它尚未保存在数据库中。 但当我将其保存到数据库时,删除的条目不包括在数据库中。这是什么意思 以下是我的Jquery/Javascript代码: attendees_id=0; $(document).rea
attendees_id=0;
$(document).ready(function(){
//通过搜索添加与会者
var addMem = [];
$("#add_button").click(function(){
$('#table_select input[type="checkbox"]:checked').each(function(){
var getRow = $(this).parents('tr');
var value = (getRow.find('td:eq(2)').html()); //names
var value1 = (getRow.find('td:eq(3)').html()); //specialty
var value3 = (getRow.find('td:eq(1)').html()); //prc
var index = $.inArray(value3, addMem);
if (index >= 0){
alert('exists');
$('input[type=checkbox]').prop('checked', false).uniform('refresh');
}
else {
$('#attendee_table tr:last').after('<tr><td></td><td><input type="text" class="form-control" name="prc[' + attendees_id + ']" id="prc" value="' + value3 + '" readonly></td><td><input type="text" class="form-control" value="' + value + '" id="names" name="name[' + attendees_id + ']" readonly></td><td><input type="text" class="form-control" value="' + value1 + '" id="specialties" name="specialty[' + attendees_id + ']" readonly></td><td><input type="button" class="btn btn-warning" name="delete_btn1[' + attendees_id + ']" id="delete_btn1" onclick="deleteMem(this)" value="Delete"></td></tr>');
addMem.push(value3,value,value1);
$("#mod_search").modal('hide');
attendees_id=attendees_id+1;
}
});
});
//从添加中删除数据
function deleteNon(t){
var row = t.parentNode.parentNode;
var yes = confirm('Are you sure?');
if (yes){
document.getElementById("attendee_table").deleteRow(row.rowIndex);
console.log(row);
}
else{
event.preventDefault();
}
}
这是我的“表格选择”:
身份证件
中华人民共和国
名称
特长
“与会者表”:
不
中华人民共和国
名称
特长
行动
你能提供更多的代码吗?这还不够。是的,这是一个快速的回答。在我的代码的哪一部分你想进一步查看?我已经包括了添加数据的文本框。
function deleteMem(t){
var row = t.parentNode.parentNode;
var yes = confirm('Are you sure?');
if (yes){
document.getElementById("attendee_table").deleteRow(row.rowIndex);
console.log(row);
}
else{
event.preventDefault();
}
}
function deleteNon(t){
var row = t.parentNode.parentNode;
var yes = confirm('Are you sure?');
if (yes){
document.getElementById("attendee_table").deleteRow(row.rowIndex);
console.log(row);
}
else{
event.preventDefault();
}
}
<table class="table table-hover table-managed" id="table_select">
<thead>
<tr>
<th>ID</th>
<th>PRC</th>
<th>Name</th>
<th>Speciality</th>
</tr>
</thead>
<tbody>
<?php
$sql_search="SELECT * FROM `personal_profile`";
$sql_run=mysql_query($sql_search);
while($m=mysql_fetch_array($sql_run))
{
?>
<tr>
<td><input type="checkbox" name="member_select[]" id="member_select" value="<?php @$m['id']; ?>"></td>
<td><?php echo @$m['prc_license_num']; ?></td>
<td id="names"><?php echo @$m['lastname'].', '.@$m['firstname'].' '.@$m['middlename'];?></td>
<td id="specialties"><?php echo @$m['speciality'];?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="table table-managed table-hover" id="attendee_table">
<thead>
<tr>
<th>No.</th>
<th>PRC</th>
<th>Name</th>
<th>Speciality</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sql_select="SELECT * FROM `event_attendees` WHERE `id`='".@$_REQUEST['member_select']."'";
$sql_run=mysql_query($sql_select);
while($row=mysql_fetch_array($sql_run))
{
?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="row">
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<label class="control-label">Name</label>
</div>
<div class="col-md-3">
<input type="text" class="form-control" id="attendee_name" name="attendee_name" value="<?=@$_REQUEST['name']?>"/>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#mod_search" id="search_btn" name="search_btn" style="visibility:hidden;" >Search</button>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<label class="control-label">Specialty/Profession</label>
</div>
<div class="col-md-3">
<input type="text" class="form-control" name="specialty" id="specialty" value="<?=@$_REQUEST['speciality']?>" />
</div>
<div class="col-md-1">
<button type="button" class="btn btn-info" id="addRow" name="addRow" style="visibility:hidden;">Add</button>
</div>
</div>
</div>