在javascript和php中使用确认框

在javascript和php中使用确认框,javascript,php,Javascript,Php,我需要有一个确认框之前,删除发生。我在这里和谷歌都做了研究,但没有找到一个可行的选择,所以我希望有人能教我正确的方法 在引导中的表中显示删除按钮的函数 function operateFormatter(value, row, index) { return [ '<a class="remove" onclick="" href="deleteVendor.php?vendor_id=' + row.id + '" title="Remove">',

我需要有一个确认框之前,删除发生。我在这里和谷歌都做了研究,但没有找到一个可行的选择,所以我希望有人能教我正确的方法

在引导中的表中显示删除按钮的函数


  function operateFormatter(value, row, index) {
    return [

      '<a class="remove" onclick="" href="deleteVendor.php?vendor_id=' + row.id + '" title="Remove">',
      '<i class="fa fa-trash"></i>',
      '</a>',

      '<a class="view" href="viewVendor.php?vendor_id=' + row.id + '" title="View">',
      '<i class="fa fa-eye"></i>',
      '</a>'
    ].join('')
  }

函数运算符格式(值、行、索引){
返回[
'',
''
].加入(“”)
}
deleteVendor.php

<?php
session_start();
/* Include the database connection file (remember to change the connection parameters) */
require './db_inc.php';

/* Include the Account class file */
require './account_class.php';
/* Create a new Account object */
$account = new Account();
$user = $_SESSION['username'];
$login = FALSE;
$id = $account->getIdFromName($user);
$vendor_id = $_GET['vendor_id'];
try
{
    $login = $account->sessionLogin();



}
catch (Exception $e)
{
    echo $e->getMessage();
    die();
}

if ($login)
{
}
else
{
    header('Location: ./index.php');
} 


        $query = "DELETE FROM vendors.vendor_data WHERE id=$vendor_id";

        /* Execute the query */
        try
        {
            $res = $pdo->prepare($query);
            $res->execute();


        }
        catch (PDOException $e)
        {
           /* If there is a PDO exception, throw a standard exception */
           throw new Exception($e);
        }


?>

您可以使用此函数


要找这个吗?由于某种原因,删除函数的设计方式不允许我这样做。每次我尝试它都会使代码崩溃。您所说的删除函数是什么意思?我的表的运算符格式(请参阅上面的代码)。无论何时我试图添加你的代码,或者任何一个类似的代码,它都会使表崩溃。我能看到你的代码吗?当您添加onclick=“return confirm('您确定吗?')”``函数运算符格式(值、行、索引){return['',].join('')}时```