簡體   English   中英

確認刪除圖像的消息框?

[英]confirmation delete message box for an image?

場景是當我單擊tour_manage.php中記錄旁邊的X圖像時,這將刪除該記錄,該記錄由另一個名為delete_tour.php的php頁面執行。

我設法將彈出框添加到X圖像中,當我單擊X時,出現消息框,提示確定要刪除或取消。 但是,問題是當我單擊“確定”和/或“取消”時,兩個按鈕都刪除了記錄。

請幫助!

這些是我得到的2個腳本。 第一個腳本是tour_manage.php,第二個腳本是delete_tour.php

<script type="text/javascript">
    function confirm() {

        if(r == true) {
            window.location='delete_tour.php;
        } else {
            window.location='tour_manage.php';
        }
    }
    </script>

<a href="delete_tour.php?tid=<?php echo $tid ?>" onclick="return confirm('Are you sure you want to delete this tour?');" ><img src="images/delete  
logo icon.png"  width="15" height="15"/></a></td>`

這是delete_tour.php腳本

<?php
session_start();
include('../config.php');

$id=$_GET['tid'];

$sql=mysql_query("delete from tour where tid='$id' ");
if($sql)
{
header('location:tour_manage.php');
}
?>

更新

    <a onclick="return confirm('Are you sure you want to delete this tour?')"  href="delete_tour.php?tid=<?php echo $tid ?>">aaa</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM