弹出消息框

时间:2016-08-05 02:28:24

标签: javascript php html

我在我的表中有一个删除记录的代码,我想添加一个弹出消息"你确定要删除记录"为用户提供取消删除记录的选项。有人可以帮忙吗?

      <td class="recordCells"><div align="center"><a href="deleterecord.php?ID=<?php echo $row_rsInventory['ID']; ?>"><img src="../images/x.png" align="absmiddle" /></a></div></td>

3 个答案:

答案 0 :(得分:0)

<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>

答案 1 :(得分:0)

你可以这样在你的表格上这样做:

 <form name=FORMNAME action=ACTIONFILE method=POST onSubmit="alert('Note that deleting a record is permanent and irreversible.');">

答案 2 :(得分:0)

尝试这个示例代码先生...希望它有帮助...

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        #pop
    {
        position: absolute;
        top:0;
        left:0;
        width:100%;
        height:100%;
        background-color: rgba(0,0,0,0.5);
        display: none;
    }
    #container
    {
        position: relative;
        width:500px;
        margin:100px auto;
        background-color: white;
        border-radius: 10px;
        padding: 20px;
    }

    </style>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
</head>
<body>
<div id="pop" >
    <div id="container">
        <h1>CONFIRM</h1>
        <button id="yes">yes</button>
        <button id="no">no</button>
    </div>
</div>
<p id="stat"></p>
<button id="del">Delete file</button>

<script type="text/javascript">
    $("#del").on("click",function(event){
        event.preventDefault();
        $("#pop").show();
    })
    $("#yes,#no").click(function(){
        $("#pop").hide();
    })
    $("#yes").click(function(){
        $("#pop").hide();
        $("p#stat").html("DELETED")

        // PUT DELETE CODES HERE===============================
    })
</script>
</body>
</html>