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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:17:32+00:00 2026-06-09T10:17:32+00:00

Right now I have a table with a few items, each of which has

  • 0

Right now I have a table with a few items, each of which has an Edit icon. When the edit icon is clicked, the corresponding database ID of the item (its name) is sent via a $.get() AJAX method to process.php, which generates a JQuery UI dialog consisting of a few of that database item’s attributes.

The first item that I click on brings up the proper dialog box with all of the attributes filled in the text boxes. However, when I click a different item, the same dialog box appears with the first item’s information. Any other ones I click on still have that first item’s information in the dialog box.

What I’m guessing is happening is that the data sent back to index.php, the new div and the jquery dialog call, has already been echo’d through and appended to the page–thus I get the same first box over and over. I just can’t figure out how to fix it.

portion of index.php:

        $('#edit_link').live('click', function(e){
            var ID = $(this).attr('name');
            console.log(ID);
            $.get('process.php', {taskID: ID}, function(data){
                $('body').append(data);
            });
            e.preventDefault();
        })

…the console successfully logs each item’s taskID, so that’s not the problem.

process.php:

if(isset($_GET['taskID'])){
    $taskID = $_GET['taskID'];
    $task = TaskDB::getTask($taskID);
    $duration = $task->getDuration();
    $description = $task->getDescription();
    $deadline = $task->getDeadline();
    echo '<script>$("#dialog").dialog({
                    height: 150,
                    width: 300,
                    modal: true,
                    buttons: {
                        "Save Task": function() {
                            $( this ).dialog( "close" );
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });</script><div id="dialog" title="Edit Task" style="display:none;">
        <p>Deadline: <input type="text" style="margin-right:10px;" value="'.$deadline.'"/> Duration (hours): <input type="text" style="width:20px;" value="'.$duration.'"/></p>
        <p>Description: <input type="text" style="width: 200px;" value="'.$description.'"/></p>
    </div>';

}

The echo portion is where I think the problem is, as the previous echoed data is not cleared out if another Edit was clicked.

Any help would be greatly appreciated. Also, I’m not entirely sure if what I’m doing is the best means for carrying out this goal (having PHP generate so much html/javascript), so any suggestions regarding that would also be very much appreciated. Thanks!

  • 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-09T10:17:34+00:00Added an answer on June 9, 2026 at 10:17 am

    I think you should first remove the previous dialog from body. Try this:

    $('#edit_link').live('click', function(e){
        var ID = $(this).attr('name');
        console.log(ID);
        $("#dialog").remove(); // Delete the previous dialog
        $.get('process.php', {taskID: ID}, function(data){
            $('body').append(data);
        });
        e.preventDefault();
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a MVC3 project. Right now I have a table which has
I am writing a MVC3 project. Right now I have a table which has
Here's my problem: In my database I have a requests table, which has a
I have some code that shows results in a table Right now it will
For few days now I'm trying to solve this problem. I have table group_user,
I have few scripts loaded by cron quite often. Right now I don't store
Right now I have 3 tables: User, Roles, and User_Roles for the many-to-many association.
Good day! I right now have a function the drags an element from a
Right now I have an upload field while uploads files to the server. The
Right now I have a script that will get the last five files in

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.