Skip to content
Advertisement

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

Advertisement

Answer

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>
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement