我想根据ID值删除记录。
现在,即使我选择第二条记录,它也会删除第一条记录。
如何让它删除正确的记录?
<cfloop query="GetRecipients">
<tr>
<td><input type="text" name="id" value="1" id="deleteid"></td>
<td> <a href="" name="deleteid" class="deleteidhere" >Remove</a></td>
</tr>
<tr>
<td><input type="text" name="id" value="2" id="deleteid"></td>
<td> <a href="" name="deleteid" class="deleteidhere" >Remove</a></td>
</tr>
</cfloop>
<script>
$(document).ready(function(){
$(".deleteidhere").click(function(e){
// alert(deleteid);
if(confirm("Are you sure you want to delete record?")){
e.preventDefault();
$.ajax({type: "POST",
url: "delete_check_Recipents.cfc?method=deleteids",
data: { id: $("#deleteid").val() },
success:function(result){
$("#deleteidhere").html(result);
window.location.href = "dates.cfm?recipient";
}});
}
else{
return false;
}
})
});
</script>
答案 0 :(得分:0)
两个记录都有相同的ID。我在下面更改了这个以获得正确的元素。不建议对多个元素使用相同的id。因此,用类名和html替换下面的id。
hadoop1:/usr/hdp/2.4.2.0-258/hbase/include/thrift$ thrift -verbose --gen py /usr/hdp/2.4.2.0-258/hbase/include/thrift/hbase2.thrift
Scanning /usr/hdp/2.4.2.0-258/hbase/include/thrift/hbase2.thrift for includes
Parsing /usr/hdp/2.4.2.0-258/hbase/include/thrift/hbase2.thrift for types
Program: /usr/hdp/2.4.2.0-258/hbase/include/thrift/hbase2.thrift
Generating "py"
答案 1 :(得分:0)
使用'class'而不是'id','id'应该是唯一的