【问题标题】:Get table details selected by the user in EJS?获取用户在 EJS 中选择的表详细信息?
【发布时间】:2021-04-16 12:22:57
【问题描述】:

下面是EJS 中的表格。我想删除用户选择的文件。

如何获取用户选择文件的详细信息?

<table id="myTable">
<thead>
  <tr>
    <th scope="col">Name</th>
    <th scope="col">Delete</th>
  </tr>
</thead>


<% file.forEach(function(row){ %>

<tbody>
  <tr>
    <td > <%=row.originalName%> </td>
    <td > Click Here to Delete </td>
  </tr>

  <% }) %>

【问题讨论】:

    标签: javascript node.js mongoose ejs fs


    【解决方案1】:

    您可以简单地将一个 id 传递给一个按钮,单击该按钮会调用一个使用 ajax 删除所选文件的函数。请参阅下面的示例代码:

    <% file.forEach(function(row){ %>
    
    <tbody>
      <tr>
        <td > <%=row.originalName%> </td>
        <td > <button onclick="deleteFile('<%=row.id%>')">Click Here to Delete </td>
      </tr>
      <% }) %>
      
      <script>
      deleteFile(id){
      //run ajax request to delete file
      }
     

    【讨论】:

      猜你喜欢
      • 2014-11-30
      • 2014-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多