How to send data of my textarea into every row when I click on button of it row?

时间:2017-12-18 07:35:58

标签: jquery html ajax asp.net-mvc

I have a table with a lot of columns and in my table every row has unique ids and I would like to know how to send data of %%f in every row and also rows has unique ids.in fact every row that has a element and an textarea and I when click on a element in every row my textarea has to send to my controller.that's all I intend.

enter image description here

textarea

   <table>
   @foreach (var item in Model)
       {
        <tr id="@("row"+item.StockID)">
        <td>

            <input type='checkbox' id="StockIDCheckBox" name='result' value=@item.StockID />

        </td>
         <td>
             @Html.TextAreaFor(modelItem => item.Description, new { id = "description", @row = "50", @cols = "5", @class = "form-control" })

         </td>

        <td>
            <a class="btn btn-info btn-sm" data-toggle="modal" data-target="#verify"  onclick="SaveandVerify(@item.StockID)">
                <i class="glyphicon glyphicon-ok"></i>
            </a>
        </td>
        <td>
            <a class="btn btn-danger btn-sm" data-toggle="modal" data-target="#Reject" onclick="RejectGroup(@item.StockID)">
                <i class="glyphicon glyphicon-remove"></i>
            </a>
        </td>
    </tr>
    </table>

function SaveandVerify(id) {
        $.get("/Admin/VerifyStockBuy/SaveandVerify/" + id, function (result) {
            $("#verify #myModalLabel").html(" وضعیت درخواست این کالا در این کارگاه ");
            $("#verify #myModalBody").html(result);

        });



    }
    function RejectGroup(id) {
        $.get("/Admin/VerifyStockBuy/Reject/" + id, function (result) {
            $("#Reject #myModalLabel").html("رد درخواست");
            $("#Reject #myModalBody").html(result);

        });
    }
      $(document).ready(function () {
        $('#repAll').DataTable({
            "ordering": true,
            "language": {
                "search": "جستجو",
                "paginate": {
                    "previous": "قبلی",
                    "next": "بعدی"
                },
                "sLengthMenu": "نمایش  _MENU_  ردیف",
                "sInfo": "نمایش _START_ تا _END_ ردیف از _TOTAL_ ردیف",
                "sEmptyTable": "هیچ داده ای در دسترس نیست",
                "sInfoEmpty": "نمایش 0 ردیف  از 0 ردیف",
            },
            "columnDefs": [{ width: 1000, targets: 0 }],
        });

        $("myelementI don't know").click(function () {


            var Desc = $("#description").val();
            var stockId = $("#StockIDCheckBox").val();
            alert(Desc + ":" + stockId);
            $.ajax({

                url: '/VerifyStockBuy/EditDescription/',
                data: { id: stockId, Description: Desc },
                type: 'Post',
                dataType: "text",
                success: function (data) {
                }

            });


        });


    });

0 个答案:

没有答案