2 mshzg1314 mshzg1314 于 2013.07.25 13:59 提问

jquery怎么让循环的两个文本框的值相加

怎么让两个循环出来的价格(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 />&nbsp;&nbsp;
                                        <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>
Csdn user default icon
上传中...
上传图片
插入图片