Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Get Table HTML Editor for value in jQuery

In my asp.net MVC application, There is a table that shows some values from the view model.

To update values I thought getting Id and Qty to array and pass to the controller.

Here is my Table

    <div class="card-body p-0">
      <table id="tblParts" class="table table-striped">
        <thead>
          <tr>
            <th> Part Number </th>
            <th> Description </th>
            <th> Model </th>
            <th> Order Qty </th>
            <th></th>
          </tr>
        </thead>
        <tbody> @foreach (var item in Model.OrderBy(i => i.PartNumber)) { <tr>
            <td style="display:none;"> @Html.DisplayFor(modelItem => item.Id) </td>
            <td> @Html.DisplayFor(modelItem => item.PartNumber) </td>
            <td> @Html.DisplayFor(modelItem => item.Description) </td>
            <td> @Html.DisplayFor(modelItem => item.Model) </td>
            <td id="Qty"> @Html.EditorFor(modelItem => item.OrderQty) </td>
          </tr> } </tbody>
      </table>
    </div>
    <div class="card-footer">
      <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
          <input type="button" value="Update Order" class="btn btn-success" onclick="UpdateOrder();" />
        </div>
      </div>
    </div>

This is the JQuery, Here it gets the Id But it does not get the Qty to the array.

<script >

  function UpdateOrder() {

    const Orders = $("#tblParts tbody tr").filter(function () {
      const cells = $(this).find("td");
      return cells.eq(4).text().trim() != ""
    }).map(function () {
      const cells = $(this).find("td");
      return {
        [cells.eq(0).text().trim()]: +cells.eq(4).text()
      }
    }).get()

    console.log(Orders);

    var newOrders = $.map(Orders, function (element) {
      var obj = {};
      for (var key in element) {
        obj.Id = key;
        obj.Quantity = element[key];
      }
      return obj;
    });

  } 
  </script>

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!