美文网首页
代码格式测试

代码格式测试

作者: riyihu | 来源:发表于2017-07-22 17:33 被阅读0次
     <div class="layui-form-item">
                        <label for="unit_price" class="layui-form-label">
                            <span class="x-red">*</span>购买单价
                        </label>
                            <div class="layui-input-inline">
                                <select id="unit_price" name="unit_price">
                                <option value="" selected="">请选择</option>
                                <option value="1">1元</option>
                                <option value="10">10元</option>
                                <option value="100">100元</option>
                                </select>
                            </div>
            </div>
    
            <!-- 总需人次 = 商品价格/购买单价 -->
            <div class="layui-form-item">
                <label for="max_buy" class="layui-form-label">
                    <span class="x-red">*</span>总需人次
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="max_buy" name="max_buy"
                           autocomplete="off" class="layui-input" disabled>
                </div>
            </div>
    
    
           <!--  <div class="layui-form-item">
                <label for="user_max_buy" class="layui-form-label">
                    限购单数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="user_max_buy" name="user_max_buy"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    默认为0,不限购
                </div>
            </div> -->
    
            <div class="layui-form-item">
                <button  class="layui-btn layui-btn-small" lay-filter="add" lay-submit="">
                    确认添加
                </button>
            </div>
        </form>
    
    
    <script src="/js/x-layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
            var form = layui.form();
           
            //监听提交
            form.on('submit(add)', getSubmitForm('{:url("admin/activity/save")}', {}));
    
            //计算总人次
                $('#unit_price').change(function (){
                var unit_num = $(this).val();
                var gprice = $('#good_marketprice').val();
                console.log(unit_num, gprice);
                $('#max_buy').val(Math.ceil(gprice/unit_num));
            });
    
    
        });
    
        function setGoods(good_id, goods_name,good_marketprice) {
            $('#good_id').val(good_id);
            $('#goods_name').val(goods_name);
            $('#good_marketprice').val(good_marketprice);
    
        }
    </script>
    

    相关文章

      网友评论

          本文标题:代码格式测试

          本文链接:https://www.haomeiwen.com/subject/wrvukxtx.html