ajax 获取table 动态数据列表的值

                <tbody id="productDetails">
                    <?php foreach ($info->items as $list) >
                        <tr data-item_id="<?=$list['id']?>">
                            <td><?=$list['product_name']?></td>
                            <td><img src="<?=$list['product_image']?>"></td>
                            <td><?=$list->getDiscountPriceYuan(); ?></td>
                            <td>元/<?=$list['unit']?></td>
                            <td><?=$list['qty']?></td>
                            <td><?=$list['sorting_num']?></td>
                            <!--<td><input type="text" value="<?=$list['qty']?>" name="out<?=$list['id']?>" id="<?=$list['id']?>"  size="5"/></td>-->
                            <td><?=$list['sorting_num']?></td>
                        </tr>
                    <?php endforeach?>
                </tbody>

function takeOrders(orderId,status) {
    var arr = [];
    $('#productDetails').children('tr').each(function(i, o) {
        var $tds = $(o).children('td');
        arr.push({
            "id": $(o).data('item_id'),
            "order_no":<?=$info['order_no']?>,
            "product_name": $tds.eq(0).text(),
            "discount_price": $tds.eq(2).text(),
            "unit": $tds.eq(3).text(),
            "order_quantity": $tds.eq(4).text(),
            "sorting_quantity": $tds.eq(5).text(),
            //"out_quantity": $tds.eq(6).children('input').val(),
            "out_quantity": $tds.eq(6).text()
        });
    });
    //console.log(arr);
    //return false;
    var msg;
    if(status=='take')
        msg="确认将订单状态改为已下单?";
    if(status=='out')
        msg="确认将订单状态改为已出库?";
    if (confirm(msg)) {
        $.ajax({
            type: 'GET',
            url: '<?php echo $this->createUrl("outOrders/take"); ?>',
            data: {id: orderId,order:status,param:arr},
            dataType: "json",
            success: function (data) {
                if(data.recode==1) {
                    window.location.href = "<?php echo $this->createUrl("outOrders/index"); ?>";
                }
            }
        });
    }
    return false;
}

</script>
<script type="text/javascript">
    $("#btn-export").click(function () {
        var defaultAction = $("#outForm").attr("action");
        $("#outForm").attr("action", '<?php echo $this->createUrl("outOrders/export");?>');
        $("#outForm").submit();
        $("#outForm").attr("action", defaultAction);
    });
</script>

你可能感兴趣的:(ajax 获取table 动态数据列表的值)