使用jquery模式框和ajax显示单元格表中的值 [英] Using jquery modal box and ajax to display values from cell table
问题描述
我试图通过使用Jquery模式对话框将值传递给控制器来执行UPDATE函数。但是,我在HTML表格框中显示我的值,有没有办法将表格行中的值传递给模态框?我想以某种方式做到这一点,当我点击行时,值将显示在模式中。我也不确定如何将jquery对话框链接到表格行。
这是表格
这些是为它编码
< form id =searchtable>
<% - 列表表格 - %>
< tr>
< th width = 9.7%> ID< / th>
< th width = 24%>使用者名称< / th>
< th width = 13>>帐户ID< / th>
< th width = 29%>电子邮件< / th>
< th width = 10%>用户ID< / th>
< th width = 12>>装置ID< / th>
< / tr>
< / table>
< div style =height:250px; overflow:scroll; width:100%;>
< table id =normal>
< 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:每个>
< / table>
< / div>
< / form>
这是对话框应该如何显示的一个例子
非常感谢你们。如果需要的话,我可以给你们提供代码。
解决方案使用.btn类到你的tr并包含你的用户名值
< span class =username> $ {it.username}< / span>
您的jquery应该
$(document).ready(function(){
$(。btn tr)。live(click,function {
var name = $(this)。 find(。username)。text();
...把你的代码放到这里来更新你的表...
});
});
如果你点击tr,它会找到它的子类为username并且会得到数据为你。
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
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
Thank you guys so much. If needed, I can provide you guys with the codes.
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.
这篇关于使用jquery模式框和ajax显示单元格表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!