2016-08-05 95 views
0

当我点击取消弹出消息它仍然删除记录,我不知道为什么。弹出框错误

<tr> 
    <td class="recordCells"> 
     <div align="center"> 
      <a onclick="confirm('Are you sure you want to delete this record?')" href="deleterecord.php?ID=<?php echo $row_rsInventory['ID']; ?>"> 
       <img src="../images/x.png" align="absmiddle"> 
      </a> 
     </div> 
    </td> 
</tr> 

回答

1

你不返回确认框的值:

<tr> 
    <td class="recordCells"> 
     <div align="center"> 
      <a onclick="return(confirm('Are you sure you want to delete this record?'))" href="deleterecord.php?ID=<?php echo $row_rsInventory['ID']; ?>"> 
       <img src="../images/x.png" align="absmiddle"> 
      </a> 
     </div> 
    </td> 
</tr> 
-2

其实,有“HREF = deleterecord.php文件”的锚标记的一个问题,所以你可以使用代码类似即:

jQuery(".confirm_click").click(function(){ 
    var check = confirm("Are you sure you want to delete this record?"); 
    if(check == true){ 
     // Action - Record deleted 
     var url= jQuery(this).attr("url"); 
     jQuery(location).attr('href',url);  
    }else{ 
     // Action - none 
    } 
    }); 

HTML代码: -

 <a class="confirm_click" href="" url="deleterecord.php?ID=<?php echo $row_rsInventory['ID']; ?>"> 
      <img src="../images/x.png" align="absmiddle"> 
     </a> 

或者您可以发送给我一部分代码“[email protected]”,我会以正确的方式进行处理。