2016-08-05 88 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]」,我會以正確的方式進行處理。