mshzg1314 2013-07-25 05:59 采纳率: 0%
浏览 5783

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>
  • 写回答

1条回答

  • 关注

    大体思路,分两种情况。
    第一种,两个价格都是直接输出的。
    每次把两个值直接计算赋值给相应的input即可。
    第二种,两个价格是可以改变的,即为输入框。
    写键盘事件,动态改变input值即可。

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题