jsp中一行多条数据情况
1.实现效果:点击新增会在之前文本框后一直新增文本框并且保留新增的图片
效果图:
2.jsp代码:
<table class="Business_Table">
<tr>
<td class="TableLabel_Left TableLabel_Tip">
<span style="float:left" class="bold">附着高度</span>
</td>
</tr>
</table>
<div style="display: none" id="fzgdTableTbodyTemp"><!--主要是为了po对象字段及显示字段问题 -->
<ww:hidden name="fzgdList[].id" id="fzgdList[]_id" />
<ww:hidden name="fzgdList[].wxyqkid" id="fzgdList[]_wxyqkid" />
<ww:hidden name="fzgdList[].lsbz" id="fzgdList[]_lsbz" />
<ww:hidden name="fzgdList[].gcid" id="fzgdList[]_gcid"/>
<ww:hidden name="fzgdList[].gccode" id="fzgdList[]_gccode"/>
<ww:hidden name="fzgdList[].cjsj" id="fzgdList[]_cjsj"/>
<div style="display: none"><ww:checkbox name="RP_VISIBLE" theme="simple" /></div>
<div style="background-color: #00bfff;" style="width: 100%;text-align:center;">第()道</div>
<div>
<ww:textfield name="fzgdList[].fzgd" id="fzgdList[]_fzgd" theme="simple"
subNum="2" precision="2" validType="length[1,6]" cssClass="txtBox easyui-numberbox" />
</div>
</div>
<div style="display: none" id="fzgdTableTbodyImg"><!--主要是为了图片的问题 -->
<td class="Page_TableText_Center" style="width: 20%" onmousemove="this.bgColor='yellow'" onmouseout="this.bgColor='#FFFFFF'">
<img src="/skin/silver/images/add.gif" alt="" onclick="addFzgd('fzgdTableTbody')"/>
<div style="display: none"><ww:checkbox name="RP_VISIBLE" theme="simple" /></div>
</td>
</div>
<table class="Page_Table_Common div_page_margin">
<ww:if test="fzgdList != null">
<tbody id="fzgdTableTbody">
<ww:iterator value="fzgdList" status="rowstatus" id="it"><!-- 因为一行显示5条数据,判断是否新增tr-->
<ww:if test="#rowstatus.index%5==0">
<tr style="height: 55px;">
</ww:if>
<td class="Page_TableText_Center" onmousemove="this.bgColor='yellow'" onmouseout="this.bgColor='#FFFFFF'"
style="width: 20%;" >
<ww:hidden name="fzgdList[${rowstatus.index}].id" id="fzgdList[${rowstatus.index}]_id" />
<ww:hidden name="fzgdList[${rowstatus.index}].wxyqkid" id="fzgdList[${rowstatus.index}]_wxyqkid" />
<ww:hidden name="fzgdList[${rowstatus.index}].lsbz" id="fzgdList[${rowstatus.index}]_lsbz" />
<ww:hidden name="fzgdList[${rowstatus.index}].gcid" id="fzgdList[${rowstatus.index}]_gcid"/>
<ww:hidden name="fzgdList[${rowstatus.index}].gccode" id="fzgdList[${rowstatus.index}]_gccode"/>
<ww:hidden name="fzgdList[${rowstatus.index}].cjsj" id="fzgdList[${rowstatus.index}]_cjsj"/>
<div style="display: none"><ww:checkbox name="RP_VISIBLE" theme="simple" /></div>
<div style="background-color: #00bfff;" style="width: 100%;text-align:center;">第(${rowstatus.index+1})道</div>
<div>
<ww:textfield name="fzgdList[${rowstatus.index}].fzgd" id="fzgdList[${rowstatus.index}]_fzgd" theme="simple"
subNum="2" precision="2" validType="length[1,6]" cssClass="txtBox easyui-numberbox" />
</div>
</td>
<ww:if test="#rowstatus.last">
<ww:if test="#rowstatus.count%5 != 0">
<td class="Page_TableText_Center" style="width: 20%"
onmousemove="this.bgColor='yellow'" onmouseout="this.bgColor='#FFFFFF'">
<img src="/skin/silver/images/add.gif" alt="" onclick="addFzgd('fzgdTableTbody')"/>
<div style="display: none"><ww:checkbox name="RP_VISIBLE" theme="simple" /></div>
</td>
</tr>
</ww:if>
<ww:else>
</tr>
<tr style="height: 45px" >
<td class="Page_TableText_Center" style="width: 20%" onmousemove="this.bgColor='yellow'" onmouseout="this.bgColor='#FFFFFF'">
<img src="/skin/silver/images/add.gif" alt="" onclick="addFzgd('fzgdTableTbody')"/>
<div style="display: none"><ww:checkbox name="RP_VISIBLE" theme="simple" /></div>
</td>
</tr>
</ww:else>
</ww:if>
<ww:elseif test="#rowstatus.count%5 == 0 && #rowstatus.index != 0">
</tr>
</ww:elseif>
</ww:iterator>
</tbody>
</ww:if>
</table>
3.js增加方法:
function addFzgd(tbodyid){
var checkls = document.getElementsByName("RP_VISIBLE").length-2;//标示当前所含有的td个数
var _copy = $("#" + tbodyid + "Temp").html(); //需要添加的html
var addHtml = $("#" + tbodyid + "Img").html();
var imgHtml = $("#" + tbodyid+" tr:last-child td:last-child").html(); //获取最后一行的最后一个td
if(checkls%5 == 0){ //此时表示如果添加则到下一行
$("#" + tbodyid).html($("#" + tbodyid).html().replace(imgHtml,_copy));
$("#" + tbodyid).append("<tr style='height: 55px'>"+addHtml+"</tr>");
} else{ //在本行添加
$("#" + tbodyid).html($("#" + tbodyid).html().replace(imgHtml,_copy));//将添加图片替换,然后新增一行
$("#" + tbodyid+" tr:last-child").append(addHtml);
}
//重置对象List下标
var listName = "";
if (tbodyid.indexOf("fzgd") != -1) {
listName = "fzgdList";
}
$("#" + tbodyid + " tr td").each(function (i) {
$(this).find("input,div").each(function () {
var fieldname = $(this).attr("name");
if (fieldname != undefined) {
fieldname = fieldname.split("].")[1]
$(this).attr("name", listName + "[" + i + "]." + fieldname);
$(this).attr("id", listName + "[" + i + "]_" +fieldname);
} else{
if($(this).text().indexOf("第(") != -1){
$(this).text("第("+(i+1)+")道");
}
}
});
});
}
4.需要做的配置:在XxxAction的同级目录下新建XxxAction-conversion.properties,文件内容为
Element_fzgdList=com.xx.xx.xx.xx.po.TpzFzgd
CreateIfNull_fzgdList=true
jsp中一行多条数据情况的更多相关文章
- 分页(将数据库中的多条数据一页一页的显示在jsp页面中)
一.显示数据库中的多条数据为什么要用分页 在真正的开发中,数据库中所存储的数据绝对不像我们平时所写的那样,仅仅有几条数据,而是有几十条甚至上百条,像淘宝京东的用户把都是上几十万甚至百万的.如果这时候在 ...
- 在SQL SERVER中获取表中的第二条数据
在SQL SERVER中获取表中的第二条数据, 思路:先根据时间逆排序取出前2条数据作为一个临时表,再按顺时排序在临时表中取出第一条数据 sql语句如下: select top 1 * from(se ...
- for循环往Oracle中插入n条数据,主键自增
1.主键自增实现方法:http://www.cnblogs.com/Donnnnnn/p/5959871.html 2.for循环往Oracle中插入n条数据 BEGIN .. loop insert ...
- 使用JDBC向数据库中插入一条数据
原谅我是初学者,这个方法写的很烂,以后不会改进,谢谢 /** * 通过JDBC向数据库中插入一条数据 1.Statement 用于执行SQL语句的对象 1.1 通过Connection 的 * cre ...
- 方法:查询MongoDB数据库中最新一条数据(JAVA)
使用JAVA语言查询MongoDB中某个数据库某个集合的最新一条数据: MongoCollection<Document> cpu = MongoClient.getDatabase(&q ...
- Bag标签之删除书包中的一条数据
删除书包中的一条数据 查询 <esql module=help id=list> Select ID,Subject,Writer,DayTime From Messages </e ...
- [MSSQL]找出一天数据中从第一条数据开始每累加1小时的数据
用Sql Server找出一天数据中从第一条数据开始每累加1小时的数据 -- ============================================= -- Author: Alle ...
- 关于如何在mysql中插入一条数据后,返回这条数据的id
简单的总结一下如何在mysql中出入一条数据后,返回该条数据的id ,假如之后代码需要这个id,这样做起来就变得非常方便,内容如下: <insert id="insertAndGetI ...
- Oracle-创建新表,创建备份表,对表中插入多条数据
一.创建新表 0.基本语法 create table 表名称(id varchar2(50) primary key ,name char(200) not null,phone number(11) ...
随机推荐
- 树莓派 - gpio-led platform driver 控制LED
树莓派3b板上有两个LED, pwr (power) 和 act (activity).是platform_driver gpio-led驱动. 可以通过设备树和gpio-led来额外控制一个LED. ...
- python 深浅拷贝&集合
一.深浅拷贝 1.浅拷贝,只会拷贝第一层 s = [1, 'ss', '小可爱'] s1 = s.copy() print(s1) >>> [1, 'ss', '小可爱'] s = ...
- 杭电 2124 Repair the Wall(贪心)
Description Long time ago , Kitty lived in a small village. The air was fresh and the scenery was ve ...
- [TyvjP1313] [NOIP2010初赛]烽火传递(单调队列 + DP)
传送门 就是个单调队列+DP嘛. ——代码 #include <cstdio> ; , t = , ans = ~( << ); int q[MAXN], a[MAXN], f ...
- python用模块zlib压缩与解压字符串和文件的方法
摘自:http://www.jb51.net/article/100218.htm Python标准模块中,有多个模块用于数据的压缩与解压缩,如zipfile,gzip, bz2等等. python中 ...
- C++对拍数据生成
#include<map> #include<ctime> #include<queue> #include<cmath> #include<cs ...
- 【ZJOI2017 Round1练习】D7T1 graph(提答)
题意: n<=1000 m<=10000 思路:
- Linux下汇编语言学习笔记4 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- linux 命令练习 2018-08-27
linux 命令练习 2018-08-27 uname 显示系统名字 [test@localhost ~]$ uname Linux uname -a 即列出linux的内核版本号 [test@ ...
- SQL SERVER 2012 第三章 T-SQL 基本语句 group by 聚合函数
select Name,salesPersonID From Sales.store where name between 'g' and 'j' and salespersonID > 283 ...