简体   繁体   English

Codeigniter 当我单击删除时,如果单击是或否,我想弹出通知

[英]Codeigniter when i click delete i want pop up notification if if click yes or not

Model:模型:

 function delete_exchange($ExchangeRateId) {
    $this -> db -> where('ExchangeRateId', $ExchangeRateId);
    $this -> db -> delete('exchange_rate');
}

Controller:控制器:

function delete($ExchangeRateId) {
        $user_type = $this -> session -> userdata('user_type');
        if ($user_type != "admin") {
            redirect(base_url() . 'user_admin/login');
        }
        $this -> all -> delete_exchange($ExchangeRateId);
        redirect(base_url() . 'exchange/index');
    }

The delete button is clear, here I want a notification like pop up yes or then must run the action I mean delete on删除按钮很清楚,在这里我想要一个通知,比如弹出是或者必须运行我的意思是删除的操作

In view Page在视图页面

<script>
function doconfirm()
{
    job=confirm("Are you sure to delete permanently?");
    if(job!=true)
    {
        return false;
    }
}
</script>

Delete Link删除链接

<a href="<?php echo site_url();?>/mycontroller/delete/<?php print($data->auc_id);?>">
   <img  src='images/delete.gif' title="Delete" onClick="return doconfirm();" >
</a>

Do like this in your view..在你看来这样做..

<a href="<?PHP site_url('delete/').$ExchangeRateId;?>" onclick="return deletechecked();">delete<?a>

    function deletechecked()
    {
        if(confirm("Delete selected messages ?"))
        {
            return true;
        }
        else
        {
            return false;  
        } 
   }

you need to do that client side.. in your view... onclick event of a button where you want the conformation use confirm() ...你需要做那个客户端......在你看来......你想要构造的按钮的onclick事件使用confirm() ......

add this to you button..将此添加到您的按钮..

<button onclick="confirmation()" />

function confirmation()
{
   var r=confirm("are you sure to delete?")
   if (r==true)
  {
    alert("pressed OK!")
    // call the controller
  }
  else
  {
   alert("pressed Cancel!");
   return false;
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我单击“添加到图表”并且通知是成功还是失败时,我想使用ajax laravel进行通知 - I want to make notification using ajax laravel when I click “Add To Chart” and the notification is Success or failed 我开发了一个api,我希望它重定向到其他php页面,并在我单击api文件中的按钮时弹出模式 - I developed a api and i want it to redirect to other php page and pop up the modal as i click the button in api file 单击循环中的数据时,我需要创建一个弹出窗口 - I need to create a pop up window when i click the data from my loop 当我使用 codeigniter 3.x 单击视图文件中的按钮时,我想插入数据库 - I want to insert in database when I click a button in my View file using codeigniter 3.x 我想单击复选框以在codeigniter中显示数据库字段的值 - I want to click the checkbox to display the database filed values in codeigniter 当我单击删除时,会显示此错误吗? - when I click delete it will display this error? 当我单击“连接到快速簿”时,出现的弹出窗口具有空白会话。 我怎样才能解决这个问题? - When I click on connect to quickbooks, the resulting pop up window has a blank session. How can I fix this? 点击按钮弹出 - Pop up on button click 我想在单击按钮时生成bool值 - I want to generate a bool value when I click a button 当我单击按钮时,我想更新数据库 - When I click the button, I want to update the database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM