这样的
我举个例子你就明白了
<input type="button" onClick=" ask = window.confirm("are you sure?"); if(ask) return true; else false;" >
这样就有了选取消不打开连接的效果

解决方案 »

  1.   

    写错了一点
    最后那里应该是
    else return false;
     写漏了一个return ^^
      

  2.   

    老大,你的window.confirm是在浏览器端执行的代码,当你看到这个确认框的时候,所有的php代码都已经执行完毕了!<?php
    echo "<script language='javascript'>\n";
    echo "if(!window.confirm('确认吗?')){self.location='sort.php?flag=confirmed'}";
    echo "</script>";
    if($confirmed){
        include("checklogin.php");
        include("../connections/conn.php");
        $sele = "delete from table where sort_id=$sort_id_dele";
        $result = mysql_query($sele) or die(mysql_error());
    }
    ?>
      

  3.   

    <script>
    function conf()
    {
    if(confirm('确认吗'))
    {
    self.location="sort.php?flag=confirmed";
    }
    }
    </script><input type=button onclick="return conf()"><?
    if($flag=="confirmed"){
        include("checklogin.php");
        include("../connections/conn.php");
        $sele = "delete from table where sort_id=$sort_id_dele";
        $result = mysql_query($sele) or die(mysql_error());
    }
    ?>