1

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

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Welcome Always
  • 367
  • 3
  • 7
  • 21

3 Answers3

8

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>
webGautam
  • 555
  • 1
  • 3
  • 14
  • @ webGutam, ((poll with codeigniter, working fine but want to redirect back if one column is duplicated)) this is my another question if u could talk a look will kind of u – Welcome Always Jun 03 '13 at 08:01
  • @WelcomeAlways great! but i did not understand your question. you want to redirect back in which condition when requested delete id is not found in table or when requested delete id is multiple in table? – webGautam Jun 03 '13 at 09:30
1

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;  
        } 
   }
Fasil kk
  • 2,147
  • 17
  • 26
0

you need to do that client side.. in your view... onclick event of a button where you want the conformation use 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;
  }
}
bipen
  • 36,319
  • 9
  • 49
  • 62