页面:content display.php

<td width="100"><a onclick="return confirmSubmit()" href="delete.php?id=<?php echo $row['id']; ?>&table=labour_details&return=content_display.php"><img src="../images/delete.png" border="0" alt="delete"></a></td>

页面:delete.php
if(isset($_GET['id']) && isset($_GET['table']))
    {
        $id=$_GET['id'];
        $tablename=$_GET['table'];
        $return=$_GET['return'];




        if($tablename=="labour_details")
        {
                    $sql=mysql_query("SELECT * FROM `labour_details` WHERE `id`='$id'");
                    $row_1=mysql_fetch_array($sql);
                    $labour_name= $row_1['labour_name'];

                    if($labour_name!="")
                    {
                        $str=mysql_query("DELETE FROM `labour_details` WHERE `id`='$id'");
                        if($str)
                        {
                            header("location:$return?msg=Record Deleted Successfully!&id=$id");
                        }else{
                            echo "Problem in deleting :";
                        }
                    }

        }

}

我的问题是在哪里添加警报,以便在删除记录之前显示javascript按摩(如果允许),它将删除记录。
function confirmSubmit()
{
    var agree=confirm("Are you sure you wish to Delete this Entry?");
    if (agree)
        return true ;
    else
        return false ;
}

最佳答案

此行将显示重定向之前的确认对话框。

<a onclick="return confirm('Are You sure?')">...</a>

关于php - php代码之前的javascript警报,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16479616/

10-10 11:55
查看更多