2012-03-21 102 views
-6
<script type="text/javascript"> 
//Confirm Delete 
function confirms(id) { 

    var test=confirm("Confirm Delete?"); 

    if(test== true) 
     window.location="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>&did="+id; 
    else 
     window.location="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>&did="+id; 
} 
</script> 
+5

不需要做'if(test == true)',這是多餘的。要麼做'if(test)'或'if(test === true)'。你有什麼是不好的。另外,你的'if'和'else'模塊完全一樣(代碼相同)。 – 2012-03-21 04:46:43

+0

if和else語句在做同樣的事情之間有什麼區別。 – punit 2012-03-21 04:48:48

+0

謝謝...這裏我管理它... – Yogs 2012-03-22 00:47:26

回答

6

它並不總是返回true。無論如何,您的腳本始終運行相同的代碼。它等同於:

<script type="text/javascript"> 
//Confirm Delete 
function confirms(id) { 
    window.location="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>&did="+id; 
} 
</script> 
+0

函數確認(ID) { var test = confirm(「確認刪除?」);如果(test == true) { window.location =「<?php echo ADMINURLPATH;?> managemenu&did =」+ id; 返回true; } } – Yogs 2012-03-22 00:41:26

+0

這是幹什麼用的? – Blender 2012-03-22 02:10:07

+0

它的任何東西....我只是對我的代碼進行更改,它運行良好..反正謝謝你的利益...... – Yogs 2012-03-22 02:53:02