Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中的引导确认对话框_Php_Javascript_Jquery_Html_Css - Fatal编程技术网

PHP中的引导确认对话框

PHP中的引导确认对话框,php,javascript,jquery,html,css,Php,Javascript,Jquery,Html,Css,如何创建删除确认对话框?如果“是”单击删除消息,如果“否”单击取消删除操作 目前我的观点是: <a href="javascript:;" class="btn btn-large btn-info msgbox-confirm">Confirm Message</a> 以及如何更改对话框内容?使用javascript的简单方法: <a onclick="if(!confirm('Are you sure that you want to permanent

如何创建删除确认对话框?如果“是”单击删除消息,如果“否”单击取消删除操作

目前我的观点是:

<a href="javascript:;" class="btn btn-large btn-info msgbox-confirm">Confirm Message</a>


以及如何更改对话框内容?

使用javascript的简单方法:

<a onclick="if(!confirm('Are you sure that you want to permanently delete the selected element?'))return false" class="btn btn-large btn-info msgbox-confirm" href="?action=delete">Delete</a>


这样,当用户单击“删除”时,一个对话框将要求她/他确认。如果它被接受,页面将使用url中的参数重新加载(更改为您需要的任何参数)。否则,对话框将关闭,什么也不会发生。

您不能在PHP中执行确认或引导确认,因为PHP是服务器端代码

您将了解如何使用Javascript创建确认框

普通Javascript

使用普通的标准javascript,这只需要一个带有函数的按钮

HTML

使用jQuery引导

在添加第三方库时,这种方法稍微复杂一些

首先,您需要创建一个模式作为确认框

HTML


函数deletechecked()
{ 
var answer=confirm(“您确定要永久删除所选元素吗?”)
若有(答复){
document.messages.submit();
}
返回false;
}

我真的不明白你的意思。您是在问如何使用JS/Jquery开发流程还是接受/拒绝,还是使用PHP使用页面重新加载,还是一般情况下?“更改对话框内容”是指什么行为?单击后按钮消失?Robert,我只是问,如果单击“是”意味着我需要调用控制器中的一个方法,如果单击“否”或“取消”,则意味着它不应该执行任何操作。PHP中用于确认对话框的代码解决了我的问题。”

拒绝和取消有什么区别?只是问…罗伯,我需要确认对话框风格如上图所示,但上面的答案解决了一半的问题
<button onclick="show_confirm()">Click me</button>
// function : show_confirm()
function show_confirm(){
    // build the confirm box
    var c=confirm("Are you sure you wish to delete?");

    // if true
    if (c){
        alert("true");
     }else{ // if false
        alert("false");
    }
  }
<div id="confirmModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Delete?</h3>
  </div>
  <div class="modal-body">
    <p>Are you sure you wish to delete?</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
    <button onclick="ok_hit()" class="btn btn-primary">OK</button>
  </div>
</div> 
<button class="btn btn-danger" onclick="show_confirm()">Click me</button>
// function : show_confirm()
function show_confirm(){
    // shows the modal on button press
    $('#confirmModal').modal('show');
}

// function : ok_hit()
function ok_hit(){
    // hides the modal
    $('#confirmModal').modal('hide');
    alert("OK Pressed");

    // all of the functions to do with the ok button being pressed would go in here
}
    <script>
function deletechecked()
{ 
    var answer = confirm("Are you sure that you want to permenantly delete the selected element?")
    if (answer){
        document.messages.submit();
    }

    return false;  
}
</script> 

<a href="<?php echo base_url('department/deletedept/'.$row['dept_id']);?>" onclick="return deletechecked();" title="Delete" data-rel="tooltip" class="btn btn-danger">