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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:15:06+00:00 2026-06-10T03:15:06+00:00

Working on a project where I want to be able to delete a dynamic

  • 0

Working on a project where I want to be able to delete a dynamic record using jQuery and PHP. I already have the option for users to add a record dynamically it is just getting the delete option to work. While I am trying to develop this function I have set the Delete to INSERT. Where I am having trouble is getting the value from the hidden field to delete-class.php (the bottom script). Below I have posted the code:

<form id="frmDelete" method="post" action="delete-class.php">
            <input id="btnSubmit" type="submit"/> 

            <ul id="class">
                <?php
//this is being loaded from a different page and is here just to reference the fields
                 while ($row = mysql_fetch_array($result)) {
                 echo '<li id="liClass" class="ui-widget"><img src="trash-can-icon.png" id='.$row["id_distance_class"].' class="delete"/>' . $row["class_section"] . '<input type="hidden" name="hdid" id="hdid" value="'.$row["id_distance_class"].'"/></li>';
                ?>
            </ul>
        </form>
<script>
        $(function() {
            $(".delete").click(function() {
                $('#load').fadeIn();
                var commentContainer = $(this).parent();
                var id = $(this).attr("id");
                var string = id ;
                // console.log(id);

                $.ajax({
                    type: "POST",
                    url: "delete-class.php",
                    data: $(this).serialize(),
                    cache: false,
                    success: function(){
                        commentContainer.slideUp('slow', function() {$(this).remove();});
                        $('#load').fadeOut();
                    }
                });
                return false;
            });
        });
    </script>
//this is the delete-class.php
$results = mysql_query("INSERT INTO distance_class (class_section) VALUES ( '".$_POST['hdid']."' ) ");
  • 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-10T03:15:07+00:00Added an answer on June 10, 2026 at 3:15 am

    The problem is you’re not passing this information in your AJAX request. You’re passing

    data: $(this).serialize()
    

    …presumably thinking this points to the form. It doesn’t; it points to the deletion button clicked, since this code is running in the button’s event handler callback.

    Change the above to target the form.

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

Sidebar

Related Questions

I am working on a PHP project where I want to be able to
I am working on a project where I want users to be able to
I'm working on a project and we want to handle our logging using log4j.
I am currently working on android project where I want to have a text
I'm working on a project where I have some hierarchical data that I want
I am working on a project using sinatra with haml for templates. I want
I'm working on a project where I want my Droid 2 to be able
I am working on a project that i want to have a plugin-sandbox like
I have a navigation based project and I want to be able to access
I'm working on a project that enables users post items they want to sell,

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.