表单新增删除行

 

开发工具与关键技术:  vs       表单新增删除行

作者:      周乐献       

撰写时间:   2019      年    7     月     8   日

 

var ArrLetter = new Array("1", "2", "3", "4", "5", "6", "7");

        function AdditionDetailOne() {

            var optionCount = $("#detail").find(".PurchaseIndent").length;

           

            if (optionCount >= 7) {

                layer.msg("已经是最后一行了,不能再添加行了",

                 { icon: 0, skin: "layui-layer-molv" });

            } else {

                    var str =

                              '' +

                              '' +

                              ArrLetter[optionCount] +

                              '' +

                              ' + optionCount + '"value=" " name="PJBM" />' +

                              ' + optionCount + '"value="" />' +

                              ' + optionCount + '"value="" name="PurchaseGG" />' +

                              '' +

                              ' + optionCount + '"value="" name="PurchaseDW" />' +

                              ' + optionCount + '"value="" name="PurchaseDJ" />' +

                              ' + optionCount + '"value="" name="PurchaseSL" />' +

                              ' + optionCount + '"value="" name="PurchaseZK" />' +

                              ' + optionCount + '"value="" name="PurchaseJE" />' +

                              '';

                    $("#detail").append(str);

 

                    createSelect("PurchaseCX" + optionCount + "", "MotorcycleType");

 

 

            }  

        }

 

        function DeleteDetailOne() {

            var optionCount = $("#detail").find(".PurchaseIndent").length;

            if (optionCount > 1) {

                $("#detail").find(".PurchaseIndent").last().remove();

            } else {

                layer.msg("第一行不能删除", { icon: 0, skin: "layui-layer-molv" });

            }

        }

默认存在一行

点击一次新增按钮增加一行

var ArrLetter = new Array("1", "2", "3", "4", "5", "6", "7");

引用对象ArrLetter,判断表行只能存在七行

if (optionCount > 1)

判断最后一行不能删除

你可能感兴趣的:(表单新增删除行)