how to pass contents of an html table as form data on a POST?

前端 未结 5 826
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 13:58

I have a list of groups in a to add the selected group to a

5条回答
  •  一生所求
    2020-12-16 14:57

    I did something like this the other day, my solution was to create an array of objects from my table that I could sent to a web service. The web service should expect an array of objects.

    // Read all rows and return an array of objects
    function GetAllRows()
    {
        var myObjects = [];
    
        $('#table1 tbody tr').each(function (index, value)
        {
            var row = GetRow(index);
            myObjects.push(row);
        });
    
        return myObjects;
    }
    
    // Read the row into an object
    function GetRow(rowNum)
    {
        var row = $('#table1 tbody tr').eq(rowNum);
    
        var myObject = {};
    
        myObject.ChangeType = row.find('td:eq(1)').text();
        myObject.UpdateType = row.find('td:eq(2)').text();
        myObject.CustomerPart = row.find('td:eq(3)').text();
        myObject.ApplyDate = row.find('td:eq(9)').text();
        myObject.Remarks = row.find('td:eq(10)').text();
    
        return myObject;
    }
    

提交回复
热议问题