怎么让两个循环出来的价格(reship文本框)旳值相加赋到(reship.reshipPrice文本框)
需要动态更新 每次更改deliveryQuantity文本框(数量) 时总金额要改变
//jquery代码
// 文本框的值改变时
$reshipDeliveryQuantity.keyup( function() {
var $this = $(this);
var maxDeliveryQuantity = $this.attr("maxDeliveryQuantity");
if (/^[0-9]*[1-9][0-9]*$/.test($this.val()) && parseInt($this.val()) > parseInt(maxDeliveryQuantity)) {
$.dialog({type: "warn", content: "本次退货数超出已发货数!", modal: true, autoCloseTime: 2000
});
$this.val(maxDeliveryQuantity);
var deliveryQuantity = document.getElementById("deliveryQuantity");
deliveryQuantity.value = "";
deliveryQuantity.focus();
return false;
}else
{
$.each($(this),function(i,val){
var $price = $(this).parent().next(".qweqweqweqwe").find("input:hidden").val();
$(this).parent().next(".qweqweqweqwe").find("input[name='reship']").val(val.value * $price);
$reshipreshipPrice.val((val.value-0) * ($price-0));
});
}
});
//java代码
<!-获取商品单价->
<input type="hidden" id="productPrice" class="formText productPrice" value="${orderItem.productPrice}"/>
<input type="hidden" id="reship" name="reship" value=""/>
<!--保存退货金额-->
<input type="hidden" id="pprice" name="pprice" value="0"/>
<!--本次退货总金额-->
<input type="hidden" id="reshipPrice" name="reshipPrice" value="${order.totalAmount}"/>
</td>
</tr>
</#list>
<tr class="zxczxczxczxc">
<td colspan="5">
<div class="buttonArea">
<input type="submit" class="formButton" value="确 定" hidefocus />
<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返 回" hidefocus />
</div>
</td>
<td class="qweqweqweqwe">
<input algin="right" type="text" id="reship.reshipPrice" name="reship.reshipPrice" class="formText reshipreshipPrice zzzzzz" value="${order.totalAmount}" style="width: 50px;" />
</td>
大体思路,分两种情况。
第一种,两个价格都是直接输出的。
每次把两个值直接计算赋值给相应的input即可。
第二种,两个价格是可以改变的,即为输入框。
写键盘事件,动态改变input值即可。