javaee从数据库中查询到数据用js或jQuery显示成表格

javaee从数据库中查询到数据用js或jQuery显示成表格,第1张

你为何不用 jsp写呢? js还要拼装 表格语句 倒不如jsp省事

<table width="500" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="60" height="20" style="background-color:#CCCCCC;">

<a>序号</a>

</td>

<td width="210" height="20" style="background-color:#CCCCCC;">

<a>论文题目</a>

</td>

<td width="70" height="20" style="background-color:#CCCCCC;">

<a>第一作者</a>

</td>

<td width="100" height="20" style="background-color:#CCCCCC;">

<a>其他</a>

</td>

<tr>

<s:iterator value="thesises" status="st">

<tr>

<td name="id" width="60" height="20">

<s:property value="id"/>

</td>

<td width="210" height="20">

<s:property value="title"/>

</td>

<td width="70" height="20">

<s:property value="firstAuthor"/>

</td>

<td width="100" height="20">

<!-- <a href="<s:url action="prize_details_%{prize_id}"/>">详情</a>-->

<a href="<s:url action="thesis/thesis_update_from_%{thesis_id}"/>">修改</a>

<a href="<s:url action="thesis/thesis_delete_%{thesis_id}"/>" onclick="return confirm('确定将此记录删除')">删除</a>

<tr>

</s:iterator>

</table>

当都选其中某几项时,如果需要给服务端ajax传递对应项的id值,该如何做呢?

思路应该是这样的:

①获取被勾选项(即checked的checkbox所在行)

②将id存在checkbox所在input的自定义属性中,如 data-id 中

③创建空数组,遍历被选中的checkbox所在行,获取对应的 data-id 值,存入数组中

④将存入的数组转化为字符串,并用逗号隔开(join(','))

<table class="table table-hover" id="test123">

<tr>

<th width="45">选择</th>

<th width="100">驾校名称</th>

<th width="100">合作驾校名称</th>

<th width="100">申请时间</th>

<th width="100">申请状态</th>

<th width="100"> *** 作</th>

</tr>

<tr>

<td><input type="checkbox" name="id" value="1" /></td>

<td>中大驾校</td>

<td>潇湘驾校</td>

<td>2016-04-15 14:40:20</td>

<td class="tablestate">未处理</td>

<td><a class="change button border-blue button-little update" href="#">修改申请状态</a></td>

</tr>

<tr>

<td><input type="checkbox" name="id" value="1" /></td>

<td>中大驾校</td>

<td>潇湘驾校</td>

<td>2016-04-15 14:40:20</td>

<td class="tablestate">未处理</td>

<td><a class="change button border-blue button-little update" href="#">修改申请状态</a></td>

</tr>

</table>

扩展资料:

遍历同胞:

siblings():被选中时找到自己的兄弟姐妹,写法有siblings(所有的兄弟姐妹)和siblings(“同级的兄弟姐妹”)。

next():被选中时找到自己的下级,写法有   nextAll(找到所有的下级)和next(“找到下一个元素”)和nextuntil("被选中的元素的范围内的元素")。

prev(), prevAll() 以及 prevUntil() 方法的工作方式与上面的方法类似,只不过方向相反:它们返回的是前面的同胞元素(在 DOM 树中沿着同胞元素向后遍历,而不是向前)。

first():返回被选中的第一元素  ,写法 $("div p")first()css("样式") 。

last():被选中的最后一个元素,写法 $("div p")last()css(”样式“) 。

eq():返回被选中元素中有索引的元素,索引号,是从0开始不是从1开始比如treq(0)id ==dataeq[i-1]id 或者 tr[0]id = data[i-1]id。        

filter():删除真正意义上的过滤,写法  $("div ")filter("span")hide() 。

not():就是跟filter()相反的用法。

$ajax({

url:"testjson",

type:"GET",

data:"json",

},success:function(data){

$("#date")text(datastartTime);//给相应的位置设值

});

以上就是关于javaee从数据库中查询到数据用js或jQuery显示成表格全部的内容,包括:javaee从数据库中查询到数据用js或jQuery显示成表格、jQuery获取表格中checkbox被选中一行的属性数据、jQuery怎么遍历表格,获取每一列的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9636874.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存