2013-06-03 23 views
1

的是模式笨刪除我想彈出通知,如果要是點擊是或否

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

這是控制器

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'); 
    } 

刪除按鈕清晰,聽到我想要一個通知,如彈出是或必須運行的動作,我的意思是刪除

thansk in提前...

+0

循着行動調用視圖彈出,然後做Ajax調用。 –

+0

你可以使用jquery對話框,http://jqueryui.com/dialog/,它提供ok/cancel功能 – bitkot

回答

8

在視圖

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

刪除鏈接

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

@ webGutam,((與民意調查codeigniter,工作正常,但想重新回到如果一列被重複))這是我的另一個問題,如果你可以說一看你會怎麼樣 –

+0

@WelcomeAlways大!但我不明白你的問題。你想重定向回去,在哪種情況下請求 請求時刪除的ID在表中找不到或 請求時刪除的ID在表中是多個? – webGautam

+0

適合我...謝謝 – saurabh

1

不喜歡這個在你看來..

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

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

謝謝你遲到了,.. –

+0

問於2013年6月3日在7:29 | 回答6年3月13日在7:33。 不遲到的兄弟.. :) –

0

你需要做的是客戶端邊..在你的看法... onclick事件的按鈕,你想要的構象使用confirm() ...

它添加到你..按鈕

<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; 
    } 
} 
+0

謝謝,但問題的答案.. –

相關問題