<script>
function calculateSum() {
var sum = 0;
//iterate through each textboxes and add the values
$(".txt").each(function() {
//add only if the value is number
if(!isNaN(this.value) && this.value.length!=0) {
sum += parseFloat(this.value);
}
});
//.toFixed() method will roundoff the final sum to 2 decimal places
$("#sum").html(sum.toFixed(2));
}
</script>
&#13;
<table id="payout12" class="display" style="float:left; width: 100%;border-radius: 5px 5px 5px 5px;
box-shadow: 2px 2px 6px #666666;-moz-box-sizing: none;" border=1 data="${payout}" border="1">
<thead>
<h2>Discount</h2>
<td class="heading">Charge</td>
<td class="heading">Cost Before Discount</td>
<td class="heading">After Plan Discount</td>
<td class="heading">After Booking Discount</td>
</tr>
</thead>
<tbody>
<c:forEach items="${payouts}" var="payout" varStatus="row">
<tr>
<td>Base Cost</td>
<td> ${payout.baseCost.costBeforeDiscount}</td>
<td>${payout.baseCost.afterPlanDiscount}</td>
<td>${payout.baseCost.afterBookingDiscount}</td>
</tr>
<c:forEach items="${payouts}" var="payout" >
<tr>
<td>Other Charges</td>
<td>${payout.otherCharges.costBeforeDiscount1}</td>
<td>${payout.otherCharges.afterPlanDiscount1}</td>
<td>${payout.otherCharges.afterBookingDiscount1}</td>
</tr>
</c:forEach>
&#13;
我在网站视图中有一个包含3列和4行的表格。我需要添加列值并在表格底部显示为总计。我使用的是spring mvc3。如何计算JSP中的总和?
但这个代码我上网了。它的输入类型是&#34; text&#34;。我的要求是将从db检索到的列的值添加到表
表格似乎
&#13;
<script>
function calculateSum() {
var sum = 0;
//iterate through each textboxes and add the values
$(".txt").each(function() {
//add only if the value is number
if(!isNaN(this.value) && this.value.length!=0) {
sum += parseFloat(this.value);
}
});
//.toFixed() method will roundoff the final sum to 2 decimal places
$("#sum").html(sum.toFixed(2));
}
</script>
&#13;
充电费用除了折扣费用后折扣 基本费用123546 111112 othert收费114523 104523