这里是我的JavaScript代码:

<script> 

     function call() { 
      $('<div></div>').appendTo('body') 
        .html('<div><h6>Yes or No?</h6></div>') 
        .dialog({ 
         modal: true, title: 'message', zIndex: 10000, autoOpen: true, 
         width: 'auto', resizable: false, 
         buttons: { 
          Yes: function() { 
           doFunctionForYes(); 
           $(this).dialog("close"); 
          }, 
          No: function() { 
           doFunctionForNo(); 
           $(this).dialog("close"); 
          } 
         }, 
         close: function (event, ui) { 
          $(this).remove(); 
         } 
        }); 
     } 

     function doFunctionForYes() { 
      alert("Yes"); 
      $('#msg').show(); 
     } 

     function doFunctionForNo() { 
      alert("No"); 
      $('#msg').show(); 
     } 

    </script> 
+0

什么是确切的问题? –

+0

我做了一个警报箱,它应该提示是或否,以便进一步处理。相反,它会直接删除它,而不会提示Y/N。 –

你必须做出一些改变:

echo "<td><a name='delete' href='product_listing_delete.php?id=" . $row['id'] . "' onclick='call()' >Delete</a></td><tr>"; 

这将直接删除您的记录,而不会提示任何形式的提醒,因为您提供了直接删除的URL。

进行这些更改:

echo "<td><a name='delete' class='delete' id='".$row['id']."'>Delete</a></td><tr>"; 

JS:

$('.delete').click(function(){ 
    if(confirm('Are you sure')) 
    { 
     var id = $(this).attr('id'); 
     // ajax call to delete the record on the behalf of id 
    } 
}); 

相关推荐