Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6868277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:24:51+00:00 2026-05-27T03:24:51+00:00

I have a table that displays from db all infrastructures (their name, description, performance).

  • 0

I have a table that displays from db all infrastructures (their name, description, performance). The last column of this table has checkbox. After selecting a few checkboxes, I want to have one button, which will delete all selected infrastructures. Here you have code of the table.

<table>
<tr>
    <th>
        Nazwa //name
    </th>
    <th>
        Opis // description
    </th>
    <th>
        Wydajność // performance
    </th>
    <th>
        zaznacz  // select
    </th>
</tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Nazwa)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Opis)
        </td>
        <td style="text-align: center">
            @Html.DisplayFor(modelItem => item.Wydajnosc) j
        </td>
        <td style="padding-left: 2%; padding-right: 2%;">
            <input type='checkbox' id='myCheckbox' name='Infrastuktura[@item.InfrastrukturaID].myCheckbox' value='@item.InfrastrukturaID' />
        </td>
    </tr>
}

I know that I need to have some variable, which will save all value from checkboxes. I had something like that: ( but it didnt’t work well )

var checked = $('input[type="checkbox"]#myCheckbox').attr('checked');

And then I must send this data ( using for example jQuery.post() ), I wrote a few functions, which send post with data, but none of them work properly. Below I put one of those functions:

    $('#submitButton').click(function () {
    if (checked) {
        $.ajax({
            type: 'POST',
            url: '/Home/InfrastrukturaDelete',
            data: 'id: ' +checked,
            contentType: 'json',
            dataType: 'json'
        });
    }
    else {
        alert("ble");
    }
});

Here is my method in HomeController:

    [HttpPost]
    public ActionResult InfrastrukturaDelete(int[] myCheckbox)
    {
        foreach (int item in myCheckbox)
        {
            Infrastruktury infrastruktura = naukaRepository.GetInfrastruktura(item);
            naukaRepository.DeleteInfrastruktura(infrastruktura);
            naukaRepository.Save();
        }

        return RedirectToAction("InfrastrukturyView");
    }

I always get error 500 or Resource interpreted as Other but transferred with MIME type undefined. Also if you can, show me how controller should look, to handle this ajax function. I will be grateful for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:24:51+00:00Added an answer on May 27, 2026 at 3:24 am

    My td with checkbox looks like that:

    <td style="padding-left: 2%; padding-right: 2%;">
         <input type='checkbox' id='myCheckbox' name='InfrastukturaID' value='@item.InfrastrukturaID' />
    </td>
    

    My script with post:

    <script type="text/javascript">
        function deleteRow() {
            if ($(':checkbox:checked')) {
                var postData = $('input[type="checkbox"]').serialize();
                $.post('/Home/InfrastrukturaDelete', postData,
                function () {
                    $(':checkbox:checked').each(function () {
                        if (this.checked) {
                            $(this).closest('tr').detach();
                        }
                    });
                });
            }
        };
    </script>
    

    Third argument in $.post() is function which dynamically delete tr, which contains checked checkboxes. My action in controller looks like that:

        [HttpPost]
        public ActionResult InfrastrukturaDelete(int[] InfrastukturaID)
        {
            foreach (int item in InfrastukturaID)
            {
                    Infrastruktury infrastruktura = naukaRepository.GetInfrastruktura(item);
                    naukaRepository.DeleteInfrastruktura(infrastruktura);
                    naukaRepository.Save();
            }
            return Content("OK");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an employee table that displays the employee number, name, and manager's employee
Many applications have grids that display data from a database table one page at
I have a page that displays a table in two different modes. In each
So I have a list box that displays averages in a table like format
I have a webpage on my site that displays a table, reloads the XML
I have a UITableViewController that when opened displays a table of the following object:
I have a web page that displays a list of events. By default all
I have a form that displays a list of systems along with their current
i have one table where one column name is city. for every user i
Let's say you have a form with a component that displays data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.