账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    js代码只能接受收到数据库遍历的第一条数据里面的数据。
    55
    0

    想实现改物品数量物品总价也跟着改动,由于不懂JS左查右查勉强实现了效果。但是购物车有两条数据的时候只有第一条有效。
    这是下面是代码:

    <volist name='list1' id='vo'>
                        <tr>
                            <td><img height=80px width=150px src="__PUBLIC__/goods/{$vo.img_address}" alt="13"></td>
                            <td>{$vo.goods_name}</td>
                            <td>{$vo.goods_describe}</td>
                            <td class='goodsprice'><strong>{$vo.goods_price}</strong></td>
                            <td><input  type="number" id="myNumber" name="quantity" min="1" max="500" value='{$vo.goods_count}' onclick="myFunction()"></td>
                            <td><strong id="allprice">{$vo.order_price}</strong></td>
                            <td><span class="red"><i class="fa fa-times" aria-hidden="true"></i></span></td>
                        </tr> 
                        </volist>

    这是js代码

    <script>
    function myFunction() {
        var x = document.getElementById("myNumber").value;    
        var text=document.querySelector(".goodsprice strong").innerHTML;
        var allprice=text*x+10
        document.getElementById("allprice").innerHTML = allprice;
        
    }
    </script>

    求大神教怎么改,另为js取到这些值怎么传到控制器方法里面去

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部