使用jquery模态对话框和AJAX来显示从细胞表中的值(Using jquery modal bo

2019-10-17 15:08发布

我试图通过使用jQuery模式对话框的值传递给控制器​​做一个更新的功能。 不过,我在一个HTML表框,显示我的价值观,有没有办法从表行的值传递给模式对话框? 我想这样做的方式当我点击该行,该值将在模式显示。 我也不清楚如何jQuery的对话框链接到表行。

这是表

这些都是它的代码

<form id="searchtable" >
               <%--List Table--%>
               <table border = 1 cellpadding = 2  cellspacing = 2 id="normal">
              <tr>
                 <th width=9.7%>ID</th>
                 <th width=24%>Username</th>     
                 <th width=13%>Account ID</th>
                 <th width=29%>Email</th>
                 <th width=10%>User ID</th>
                 <th width=12%>Device ID</th>         
              </tr>
         </table>

              <div style="height: 250px; overflow: scroll; width: 100%;">
              <table id="normal">
              <g:each in = "${result}">
              <tr>
              <td width=10%>${it.ID}</td>
              <td width=25%>${it.Username}</td>
              <td width=13.5%>${it.account_id}</td>
              <td width=30.5%>${it.email}</td>
              <td width=10.5%>${it.user_id}</td>
              <td width=13%>${it.device_id }</td>
              </tr>
              </g:each>


              </table>
         </div>        
    </form>

这是它应该出现的对话框的例子

谢谢你们这么多。 如果需要,我可以为您提供的代码的家伙。

Answer 1:

使用.btn类的tr和您的用户名值到附寄

<span class="username">${it.username}</span>

您的jQuery应该

$(document).ready(function() {
  $(".btn tr").live("click", function{
    var name = $(this).find(".username").text();
    ...put your code here that will update your table...
  });
});

如果你点击TR时,会发现其子带班“用户名”和将得到的数据为您服务。



文章来源: Using jquery modal box and ajax to display values from cell table