Using jquery modal box and ajax to display values

2019-08-04 17:28发布

I'm trying to do an UPDATE function by using Jquery modal dialog box to pass the values to the controller. However, I'm displaying my values in a HTML table box, is there a way to pass the values from the table row to the modal box? I want to do it in a way when i click the row, the values will be displayed in the modal. I'm also unsure of how to link a jquery dialog box to a table row.

This is the table

enter image description here

These are the codes for it

<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>

This is an example of the dialog box of how it should appear

enter image description here

Thank you guys so much. If needed, I can provide you guys with the codes.

1条回答
Fickle 薄情
2楼-- · 2019-08-04 17:55

use .btn class to your tr and inclose your username value to

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

your jquery should

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

if you click the tr, it will find its child with class "username" and will get the data for you.

查看更多
登录 后发表回答