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 7161393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:33:34+00:00 2026-05-28T13:33:34+00:00

I’m able to delete one entry at a time using AJAX. Now I’ve made

  • 0

I’m able to delete one entry at a time using AJAX. Now I’ve made the possibility to select entries using a checkbox and delete them all simultaneously, this works great without AJAX. Now I’m trying to delete multiple entries using AJAX. This is what I have so far:

the ajax:

`$(function() {
$(".checkbox_button_del").click(function() {
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parents('tr:first');

                        var notice = '<div class="notice">'
                                  + '<div class="notice-body">' 
                                      + '<img src="core/displays/notify/delete-icon.png" alt="" />'
                                      + '<h3>Deleted item</h3>'
                                      + '<p>The item has been succesfully deleted.</p>'
                                  + '</div>'
                                  + '<div class="notice-bottom">'
                                  + '</div>'
                              + '</div>';

                        $ny( notice ).purr(
                            {
                                usingTransparentPNG: true
                            }
                        );
$.ajax({
type: "POST",
url: "core/actions/delete_multiple.php",
data: dataString,
cache: false,

success: function()
{
parent.fadeOut('300', function() {$(this).remove();});
    $("#load_tasklist").load("core/statistics/stats_brackets.php")
    $("#load_tweets").load("response.php")
    $("#load_mod_day_summary").load("core/displays/mod_day_summary.php")
    $("#load_mod_task_selector").load("core/displays/mod_task_selector.php")
}
});

return false;
});
});`

the external deleting script:`

include('../../core/additional/connect-db.php');

    for($i=0;$i<count($_POST["chkDel"]);$i++)
    {
        if($_POST["chkDel"][$i] != "")
        {
            $strSQL = "DELETE FROM players ";
            $strSQL .="WHERE id = '".$_POST["chkDel"][$i]."' ";
            $objQuery = mysql_query($strSQL);
        }
    }



    header('Location: ' . $_SERVER['HTTP_REFERER']);`

and the result list with the delete button: `

<form name="frmMain" id="myForm" method="post" OnSubmit="return onDelete();">


<?php 

 $connection = mysql_connect($server, $user, $pass)  or die ("Could not connect to server ... \n" . mysql_error ());
 mysql_select_db($db) or die ("Could not connect to database ... \n" . mysql_error ());

    $result = mysql_query("SELECT * FROM players WHERE (userid = '$username' AND done = '0' AND measure = 'task' AND day = '$user_mydate') ORDER BY id DESC")
                    or die(mysql_error());

     echo '<div id="checkbox_button_div">
    <input class="checkbox_button_del" type="submit" id="buttondel" value="Delete" />
    <input class="checkbox_button_done" type="submit" id="buttondone" value="Done" />
    <input class="checkbox_button_done" type="submit" id="buttonfavorite" value="Favorite" />
    <input class="checkbox_button_done" type="submit" id="buttonmove" value="+1 day" />
    </div>';

     echo '

            <table id="tableOne" cellpadding="0" cellspacing="0" width="760" border="0" class="yui">    
        <thead>

            <tr>                                    

                <th><a href="#" title="Click Header to Sort">Task</a></th>

                <th><a href="#" title="Click Header to Sort">Minutes</a></th>
                <th><a href="#" title="Click Header to Sort">Time</a></th>

                <th><a href="#" title="Click Header to Sort">Category</a></th>
                <th> <input type="checkbox" class="check" value="check all" /></th>

            </tr>

        </thead>
     <tbody> ';    

        $i = 0;
        while($row = mysql_fetch_array( $result )) {   
        $i++;
            include ('core/additional/params_tasks.php');

            echo ' 

            <tr class="handcursor" onmouseover="' .($mouseover). '" onmouseout="' .($mouseout). '">         

                <td class="editable" id="' .($id). '" width="180">' .($task). ' </td>
                <td class="editable" id="' .($id). '">' .($minutes). '</td>
                <td onClick="' .($onclick). '">' .($hours_start). '.' .($minutes_start). ' - ' .($hours_due2). '.' .($minutes_due2). ' </td>
                <td onClick="' .($onclick). '">' .($categorie). ' </td>         
                <td align="center"><input type="checkbox" class="cb-element" name="chkDel[]" id="chkDel<?=$i;?>" value="' .($id). '"></td>

            </tr> ';

            }
            // close table>
            echo '</tbody>
        <tfoot>
                <tr style="display:none;">
                <td style="border: 0px;" colspan="4">
                    No matching results..
                </td>
            </tr>           
        </tfoot>
     </table>

      '; 

     ?>

    <input type="hidden" name="hdnCount" value="<?=$i;?>">

    </form>`

I think the AJAX script should pass the “$i” values as well, but I don’t know how to do this. Please tell me if the problem isn’t clear to you. Looking forward to your answer!

  • 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-28T13:33:34+00:00Added an answer on May 28, 2026 at 1:33 pm

    yout jquery would be somthing like this.

    $("#Submit1").click(function () {
    
                var arr = new Array();
    
    
                $("input:checked").each(function () {
    
                    arr.push($(this).attr("id"));
    
                }); //each
    
                $.ajax({
                 type: "POST",
           url: "core/actions/delete_multiple.php",
           data: arr ,//pass the array to the ajax call
           cache: false,
    
           success: function()
                 {   }
           });//ajax
    
                }); //each
    
    
            }); //click
    

    since the PHP function will get a JSON object. you will need to do a JSON decode to ge the array…. see JSON decode… use this array to create your query like..

       delete from SalesLT.Customer
    where CustomerID in (1,2,3,4);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.