如何使用其ID将表单元素传递给数组

时间:2019-11-08 06:35:17

标签: javascript c# html asp.net-mvc

我已经创建了对象,然后需要将这些数据存储到数组中。

使用此功能创建项目。我需要将每个项目保存到数组中。

function appendItemforPurchaseOrder() {
    debugger

    var rowNumber = parseInt($(".itemmapContainer").attr("data-rownumber"));

    rowNumber = isNaN(rowNumber) ? 1 : rowNumber + 1;

    var addNewItemDetailHtml = "<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12 itemmapWrapper custom-paaddingnone'\
                               id='itemmapWrapper" + rowNumber + "' data-rowNumber='" + rowNumber + "' >";

    addNewItemDetailHtml += "<div class='col-lg-10 col-md-10 col-sm-10 col-xs-10 custom-paaddingnone form-group'>\
                                    <div class='col-lg-1 col-md-1 col-sm-1 col-xs-1 itemclass custom-paaddingnone text-center'>" + rowNumber + "\
                                    </div>\
                                    <div class='col-lg-11 col-md-11 col-sm-11 col-xs-11 custom-paaddingnone'>\
                                        <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12 custom-paaddingnone form-group'>\
                                            <div class='col-lg-3 col-md-3 col-sm-3 col-xs-3 custom-paaddingleft' onChange='getItemCode(" + rowNumber + ")'>\
                                                <select class='form-control' id = 'itemid"+ rowNumber + "' ></select>\
                                            </div >\
                                        </div>\
                                    </div>\
                                </div >";

    addNewItemDetailHtml += "<div class='col-lg-2 col-md-2 col-sm-2 col-xs-2 form-group'>\
                                 <div class='col-lg-10 col-md-10 col-sm-10 col-xs-10'>\
                                        <input type='text' class='form-control text-right' id='totalamount"+ rowNumber + "' disabled>\
                                </div>\
                                <div class='col-lg-2 col-md-2 col-sm-2 col-xs-2'>\
                                        <span class='glyphicon glyphicon-trash removeBtn' onclick = 'removeItemDetail(this, " + rowNumber + ")' ></span >\
                                </div>\
                            </div > ";


    addNewItemDetailHtml += "</div>";

    addNewItemDetailHtml += "</div>";

    $(".itemmapContainer").attr("data-rownumber", rowNumber);
    $(".itemmapContainer").append(addNewItemDetailHtml);
    intialize_itemDropDown(rowNumber);
    intialize_Data(rowNumber);
}

还有其他一些可用的对象,但是如果有人可以用这些对象解决这个问题,那就太好了。

0 个答案:

没有答案