2015-10-26 50 views
1

我有一个具有数据表和弹出警报的代码。无论警报弹出还是不弹出,Datatable都可以正常工作,但警报弹出对数据表无法正常工作。只有没有它(数据表)才能工作。这是一个可能的代码冲突吗?该错误表明,当我尝试删除数据时,在users.js:27(第27行)中出现“TypeError:Can not set property'action undefined”。同样的事情要确认(第49行)。警报脚本:无法设置未定义的属性“操作”

这里是我的HTML(表格)代码

<table class="table table-striped datatable" id="datatables"> 
       <thead> 
        <tr> 
        <th>#</th> 
        <th>First Name</th> 
        <th>Last Name</th> 
        <th>Username</th> 
        </tr> 
       </thead> 


        <?php 
         if ($result->num_rows > 0) { // output data of each row?> 
         <tbody> 
          <?php while($row = $result->fetch_assoc()) { 
           if($row['status']=='t'){ 
         ?> 
           <form name="frmUser" action="" method="post"> 
           <?php {       //this form will display the set of pending applications 

             echo'<tr>'; 
             echo '<td>' . '<input type="checkbox" name="selected[]" value="'.$row['application_number'].'" class="checkbox-warning"/>' . '</td>'; 
             echo '<td>' . $row['application_number'] . '</td>'; 
             echo '<td>' . $row['lastname'] . '</td>'; 
             echo '<td>' . $row['firstname'] . '</td>'; 
            echo'</tr>'; 
            } 
           ?> 

         <?php } //if statement 
           } //while statement 
         ?> 
         </tbody> 
         </table> 
          <input type="button" name="delete" value="Delete" id="onDelete" /> 
          <input type="button" name="update" value="Confirm" id="onUpdate" /> 
          </form> 

         <?php 
         }else { 
          echo "0 results"; 
         } 
      ?> 

然后这里是我的 JS代码

jQuery(document).ready(function($){ 
$("#onDelete").click(function() { 
    swal({ title: "Are you sure?", 
     text: "You will not be able to recover this file!", 
     type: "warning", 
     showCancelButton: true, 
     confirmButtonColor: "#DD6B55", 
     confirmButtonText: "Yes, delete it!", 
     cancelButtonText: "No, cancel!", 
     closeOnConfirm: false, 
     closeOnCancel: false 
    }, function(isConfirm){ 
     if (isConfirm) { 
      document.frmUser.action = "temporary_applications_delete.php"; 
      document.frmUser.submit();  
      swal("Deleted!", "Application file has been deleted.", "success"); 

     } else {  
      swal("Cancelled", "Your file is safe :)", "error"); 
     } }); 

}); 

$("#onUpdate").click(function() { 
    swal({ title: "Are you sure?", 
     text: "You will UPDATE this applicant file!", 
     type: "warning", 
     showCancelButton: true, 
     confirmButtonColor: "#DD6B55", 
     confirmButtonText: "Yes, UPDATE it!", 
     cancelButtonText: "No, cancel!", 
     closeOnConfirm: false, 
     closeOnCancel: false 
    }, function(isConfirm){ 
     if (isConfirm) { 
      document.frmUser.action = "temporary_applications_process.php"; 
      document.frmUser.submit();  
      swal("Updated!", "Application file has been updated!.", "success"); 

     } else {  
      swal("Cancelled", "Your file is safe :)", "error"); 
     } }); 

}); 

});

代码出了什么问题?

回答

1

你有一个html问题,因为你打开表格标签内部的表格标签,并关闭它后,你必须关闭表格内部表格 因为html标签必须正确关闭。

+0

如果你有问题不要犹豫,再次 –

+0

没看到那个哈!大!这解决了问题。感谢您指出了这一点。 – Regina

相关问题