jsp页面内容:
隐藏域外币金额:<input type="hidden" class="foreignCurrencyAmount inn" value="${foreignCurrencyAmount}">
<td>成交汇率:<input type="text" class="ime_disabled non-negative exchangeRate" name="orderVoList[<s:property value='#index.index' />].exchangeRate"
value="${od.exchangeRate}" maxlength="10" size="10" id="exchangeRate${index.index }" />
</td>
<td>实际付款:<input type="text" class="ime_disabled non-negative paymentAmount" name="orderVoList[<s:property value='#index.index' />].paymentAmount"
value="${od.paymentAmount}" maxlength="10" size="10" id="paymentAmount${index.index }" />
<input type="hidden" name="orderVoList[<s:property value='#index.index' />].orderId" value='${od.orderId}' />
</td>
效果:从数据库中读出的数据,
外币金额 成交汇率 实际付款
100
200
150
每条数据成交汇率输入的时候,实际付款跟着变化
js代码:
$(".exchangeRate")on("keyup change", function(){
var ts = $(this);//获取当前元素成交汇率
var cxt = ts.parent().parent();//***********************************************************************************************
var foreignCurrencyAmountV = $(".foreignCurrencyAmount", cxt.parent().parent().parent().parent()).val();////////////////********************
//获取autocomplete的控件
var paymentAmount = $(".paymentAmount", cxt);//实际对应的付款
//var discountPriceI = $(".discountPriceI", cxt);
var v = Number(parseFloat(ts.val()) * foreignCurrencyAmountV).toFixed(10);
paymentAmount.val(parseFloat(v));
//discountPriceI.val(formatNumberByCurrencyCode(parseFloat(v), tp, cxt));
});