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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:50:47+00:00 2026-06-09T21:50:47+00:00

On my website, I am trying to remove (hide) an sql entry in a

  • 0

On my website, I am trying to remove (hide) an sql entry in a table without refreshing the screen.

Currently, each visible entry is displayed in a div with an id of schedule000 where 000 is the id number of the entry. Each has a delete button:

<div id="btn_delete" class="schedule-delete" onclick="deleteEvent(schedule'.$row['id'].');"></div>

while the function is

function deleteEvent(id) {
    var delurl = "..schedule/index.php?d="+String(id.id.substring(8));
    $.get(delurl);
    $(id).hide('slow');
    return false;
}

I found that get function after searching the internet but I couldn’t seem to get it to work.
I’m looking for suggestions or a new solution.

Thanks

as a side note:
this is part of the page that it is calling

if (isset($_GET['d'])) {
    $id = $_GET['d'];
    $query = "UPDATE schedule SET visible=0 WHERE id='$id'";
    if (!(mysql_query($query) or die(mysql_error()))) {
        echo 'failed to delete';
    }

EDIT: Using Sven’s method, I now have:

function del_item() {
    try {
        var item_id = $(this).attr('item_id'); 
        var item = $(this).parent().parent(); //parent().paren... until you reach the element that you want to delete 
        $.ajax({
          type: 'POST',
          url: "../schedule/index.php",
          data: { id: item_id},
          success: function() {
              //fade away and remove it from the dom
              $(element).fadeOut(300, function() { $(this).remove(); });
          },
          error: function() {
              alert('failed to delete');
          }
        });
    } catch (err) {
        alert(err.message);
    }
}

along with the document ready function and

if (isset($_POST['action'])) {
    if ($_POST['action'] == 'd' && isset($_POST['id'])) {
        $id = $_POST['id'];
        $query = "UPDATE schedule SET visible=0 WHERE id='$id'";
        if (!(mysql_query($query) or die(mysql_error()))) {
            echo 'failed to delete';
        }
        die("J! :)");
    }
  • 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-06-09T21:50:48+00:00Added an answer on June 9, 2026 at 9:50 pm

    I would do it like this:

    Add the item id to the delete button like this:

    <div id="btn_delete" class="schedule-delete" item_id="' . $row['id'] . '"></div>
    

    ​The javascript of that page:

    function del_item() {
        var item_id = $(this).attr('item_id'); 
        var item = $(this).parent(); //parent().paren... until you reach the element that you want to delete 
    
        $.ajax({
          type: 'POST',
          url: "url_to_your_remove_script.php",
          data: { id: item_id},
          success: function() {
              //fade away and remove it from the dom
              $(item).fadeOut(300, function() { $(this).remove(); });
          },
          error: your_error_func
        });
    }
    
    ​$(document).ready(function() {
        $('.schedule-delete').click(del_item);
    });​
    

    And for the php delete page (url_to_your_remove_script.php):

    <?php
        if(isset($_POST['id'])) {
            //your update query here
    
            die("J! :)");
        }
    
        //no id, return error
        header('HTTP/1.1 500 Internal Server Error :(');
    ?>
    

    You can find more information about $.ajax here: click.

    Hope this helps.

    PS: Didn’t tested the code, but it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a business website I'm trying to achieve the following: - A div with
I am trying to remove an element from a div on a third party
I'm trying to remove an area of my website with detach because I have
I am trying to remove all logging and tracing errors on a company website
For my wordpress website I am trying to remove the Google timestamp that is
I'm trying to update a tuple in a table using php and sql via
I am trying to create a chrome extension that will remove/block/hide a piece of
For my wordpress website I am trying to remove the Google timestamp that is
I was trying to remove index.php from the URL of a Magento website: _Turn
I'm trying to publish an asp.net website on a remote server. When my code

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.