jsp页面对查询的数据进行汇总计算
这是查询结果显示的代码<tableclass="table"width="100%"><thead><tr><thwidth="80">产品类别</th><thwidth...
这是查询结果显示的代码
<table class="table" width="100%" >
<thead>
<tr>
<th width="80" >产品类别</th>
<th width="80">楞型</th>
<th width="80" >上期平方</th>
<th width="80" >入库平方</th>
<th width="80" >出库平方</th>
<th width="80">退货平方</th>
<th width="80" >退车间平方</th>
<th width="80" >调整平方</th>
<th width="80" >结存平方</th>
</tr>
</thead>
<% while(rs.next()){ %>
<tbody>
<tr target="sid_user">
<td width="80" ><%=rs.getString(1)%></td>
<td width="80"><%=rs.getString(2)%></td>
<td width="80"><%=rs.getString(3)%></td>
<td width="80"><%=rs.getString(4)%></td>
<td width="80"><%=rs.getString(5)%></td>
<td width="80"><%=rs.getString(6)%></td>
<td width="80" ><%=rs.getString(7)%></td>
<td width="80" ><%=rs.getString(8)%></td>
<td width="80"><%=rs.getString(9)%></td>
</tr>
<tr target="sid_user" ">
<%} %>
现在想在结果最底下添加一条没一列汇总记录 展开
<table class="table" width="100%" >
<thead>
<tr>
<th width="80" >产品类别</th>
<th width="80">楞型</th>
<th width="80" >上期平方</th>
<th width="80" >入库平方</th>
<th width="80" >出库平方</th>
<th width="80">退货平方</th>
<th width="80" >退车间平方</th>
<th width="80" >调整平方</th>
<th width="80" >结存平方</th>
</tr>
</thead>
<% while(rs.next()){ %>
<tbody>
<tr target="sid_user">
<td width="80" ><%=rs.getString(1)%></td>
<td width="80"><%=rs.getString(2)%></td>
<td width="80"><%=rs.getString(3)%></td>
<td width="80"><%=rs.getString(4)%></td>
<td width="80"><%=rs.getString(5)%></td>
<td width="80"><%=rs.getString(6)%></td>
<td width="80" ><%=rs.getString(7)%></td>
<td width="80" ><%=rs.getString(8)%></td>
<td width="80"><%=rs.getString(9)%></td>
</tr>
<tr target="sid_user" ">
<%} %>
现在想在结果最底下添加一条没一列汇总记录 展开
3个回答
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY >
<table class="table" width="100%" >
<thead>
<tr>
<th width="80" >产品类别</th>
<th width="80">楞型</th>
<th width="80" >上期平方</th>
<th width="80" >入库平方</th>
<th width="80" >出库平方</th>
<th width="80">退货平方</th>
<th width="80" >退车间平方</th>
<th width="80" >调整平方</th>
<th width="80" >结存平方</th>
</tr>
</thead>
<tbody>
<% while(rs.next()){ %>
<tr target="sid_user">
<td width="80"><%=rs.getString(1)%>
<input type="hidden" name="data1" value="<%=rs.getString(1)%>
"/></td>
<td width="80"><%=rs.getString(2)%>
<input type="hidden" name="data2" value="<%=rs.getString(2)%>
"/></td>
<td width="80"><%=rs.getString(3)%>
<input type="hidden" name="data3" value="<%=rs.getString(3)%>
"/></td>
<td width="80"><%=rs.getString(4)%>
<input type="hidden" name="data4" value="<%=rs.getString(4)%>
"/></td>
<td width="80"><%=rs.getString(5)%>
<input type="hidden" name="data5" value="<%=rs.getString(5)%>
"/></td>
<td width="80"><%=rs.getString(6)%>
<input type="hidden" name="data6" value="<%=rs.getString(6)%>
"/></td>
<td width="80"><%=rs.getString(7)%>
<input type="hidden" name="data7" value="<%=rs.getString(7)%>
"/></td>
<td width="80"><%=rs.getString(8)%>
<input type="hidden" name="data8" value="<%=rs.getString(8)%>
"/></td>
<td width="80"><%=rs.getString(9)%>
<input type="hidden" name="data9" value="<%=rs.getString(9)%>
"/></td>
</tr>
<%} %>
<tr>
<td width="80" id="sum1"></td>
<td width="80" id="sum2"></td>
<td width="80" id="sum3"></td>
<td width="80" id="sum4"></td>
<td width="80" id="sum5"></td>
<td width="80" id="sum6"></td>
<td width="80" id="sum7"></td>
<td width="80" id="sum8"></td>
<td width="80" id="sum9"></td>
</tr>
</tbody>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function heji(){
for(var j=1;j<=9;j++){
var str = ' var data'+j+'s = document.getElementsByName("data'+j+'");var sum'+j+' = 0.0;for(var i=0;i<data'+j+'s.length;i++){sum'+j+' +=parseFloat(data'+j+'s[i].value);}document.getElementById("sum'+j+'").innerHTML="总计:"+sum'+j+';';
eval(str);
}
};
heji();
//-->
</SCRIPT>
</BODY>
</HTML>
统计问题常见做法是在后台准备数据,当然前台也可以,像上面那样用js做统计。
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY >
<table class="table" width="100%" >
<thead>
<tr>
<th width="80" >产品类别</th>
<th width="80">楞型</th>
<th width="80" >上期平方</th>
<th width="80" >入库平方</th>
<th width="80" >出库平方</th>
<th width="80">退货平方</th>
<th width="80" >退车间平方</th>
<th width="80" >调整平方</th>
<th width="80" >结存平方</th>
</tr>
</thead>
<tbody>
<% while(rs.next()){ %>
<tr target="sid_user">
<td width="80"><%=rs.getString(1)%>
<input type="hidden" name="data1" value="<%=rs.getString(1)%>
"/></td>
<td width="80"><%=rs.getString(2)%>
<input type="hidden" name="data2" value="<%=rs.getString(2)%>
"/></td>
<td width="80"><%=rs.getString(3)%>
<input type="hidden" name="data3" value="<%=rs.getString(3)%>
"/></td>
<td width="80"><%=rs.getString(4)%>
<input type="hidden" name="data4" value="<%=rs.getString(4)%>
"/></td>
<td width="80"><%=rs.getString(5)%>
<input type="hidden" name="data5" value="<%=rs.getString(5)%>
"/></td>
<td width="80"><%=rs.getString(6)%>
<input type="hidden" name="data6" value="<%=rs.getString(6)%>
"/></td>
<td width="80"><%=rs.getString(7)%>
<input type="hidden" name="data7" value="<%=rs.getString(7)%>
"/></td>
<td width="80"><%=rs.getString(8)%>
<input type="hidden" name="data8" value="<%=rs.getString(8)%>
"/></td>
<td width="80"><%=rs.getString(9)%>
<input type="hidden" name="data9" value="<%=rs.getString(9)%>
"/></td>
</tr>
<%} %>
<tr>
<td width="80" id="sum1"></td>
<td width="80" id="sum2"></td>
<td width="80" id="sum3"></td>
<td width="80" id="sum4"></td>
<td width="80" id="sum5"></td>
<td width="80" id="sum6"></td>
<td width="80" id="sum7"></td>
<td width="80" id="sum8"></td>
<td width="80" id="sum9"></td>
</tr>
</tbody>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function heji(){
for(var j=1;j<=9;j++){
var str = ' var data'+j+'s = document.getElementsByName("data'+j+'");var sum'+j+' = 0.0;for(var i=0;i<data'+j+'s.length;i++){sum'+j+' +=parseFloat(data'+j+'s[i].value);}document.getElementById("sum'+j+'").innerHTML="总计:"+sum'+j+';';
eval(str);
}
};
heji();
//-->
</SCRIPT>
</BODY>
</HTML>
统计问题常见做法是在后台准备数据,当然前台也可以,像上面那样用js做统计。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询