[英]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.