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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:32:59+00:00 2026-05-14T06:32:59+00:00

I have a form that adds links to a database, deletes them, and —

  • 0

I have a form that adds links to a database, deletes them, and — soon — allows the user to edit details. I am using jQuery and Ajax heavily on this project and would like to keep all control in the same page. In the past, to handle editing something like details about another website (link entry), I would have sent the user to another PHP page with form fields populated with PHP from a MySQL database table. How do I accomplish this using a jQuery UI modal form and calling the details individually for that particular entry?

Here is what I have so far-

<?php while ($linkDetails = mysql_fetch_assoc($getLinks)) {?>
<div class="linkBox ui-corner-all" id="linkID<?php echo $linkDetails['id'];?>">
<div class="linkHeader"><?php echo $linkDetails['title'];?></div>
<div class="linkDescription"><p><?php echo $linkDetails['description'];?></p>
<p><strong>Link:</strong><br/>
<span class="link"><a href="<?php echo $linkDetails['url'];?>" target="_blank"><?php echo $linkDetails['url'];?></a></span></p></div>
<p align="right">
<span class="control">
<span class="delete addButton ui-state-default">Delete</span> 
<span class="edit addButton ui-state-default">Edit</span>
</span>
</p>
</div>
<?php }?>

And here is the jQuery that I am using to delete entries-

$(".delete").click(function() {
      var parent = $(this).closest('div');
      var id = parent.attr('id');
      $("#delete-confirm").dialog({
                     resizable: false,
                     modal: true,
                     title: 'Delete Link?',
                     buttons: {
                         'Delete': function() {
      var dataString = 'id='+ id ;
         $.ajax({
         type: "POST",
         url: "../includes/forms/delete_link.php",
         data: dataString,
         cache: false,
         success: function()
         {
          parent.fadeOut('slow');
          $("#delete-confirm").dialog('close');    
         }
        });                                
                         },
                         Cancel: function() {
                            $(this).dialog('close');
                         }
                     }
                 });
       return false;
});

Everything is working just fine, just need to find a solution to edit. 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-05-14T06:33:00+00:00Added an answer on May 14, 2026 at 6:33 am

    *Updated to include all of the fields you are editing

    It sounds like you have the right idea. You would probably want to create a new div on your page for the edit modal dialog.

    <div id="dialog-edit" style="background-color:#CCC;display:none;">
        <input type="hidden" id="editLinkId" value="" />
        Link Name: <input type="text" id="txtLinkTitle" class="text" />
        Link Description <input type="text" id="txtLinkDescription" class="text" />
        Link URL <input type="text" id="txtLinkURL" class="text" />
    </div>
    

    When the user clicks your edit button you’ll want to populate the hidden field and the text box with the values of the link they clicked on and then turn the dialog on.

    $('.edit').click(function () {
                //populate the fields in the edit dialog. 
                var parent = $(this).closest('div');
                var id = parent.attr('id');
    
                $("#editLinkId").val(id);
    
                //get the title field
                var title = $(parent).find('.linkHeader').html();
                var description = $(parent).find('.linkDescription p').html();
                var url = $(parent).find('.linkDescription span a').attr("href");
                $("#txtLinkTitle").val(title);
                $("#txtLinkDescription").val(description);
                $("#txtLinkURL").val(url);
    
                $("#dialog-edit").dialog({
                    bgiframe: true,
                    autoOpen: false,
                    width: 400,
                    height: 400,
                    modal: true,
                    title: 'Update Link',
                    buttons: {
                        'Update link': function () {
                            //code to update link goes here...most likely an ajax call.
    
                            var linkID = $("#linkID").val();
                            var linkTitle = $("#txtLinkTitle").val()
                            var linkDescription = $("#txtLinkDescription").val()
                            var linkURL = $("#txtLinkURL").val()
                            $.ajax({
                                type: "GET",
                                url: "ajax_calls.php?function=updateLink&linkID=" + linkID + "&linkTitle=" + linkTitle + "&linkDescription=" + linkDescription + "&linkURL=" + linkURL,
                                dataType: "text",
                                error: function (request, status, error) {
                                    alert("An error occured while trying to complete your request: " + error);
                                },
                                success: function (msg) {
                                    //success, do something 
                                },
                                complete: function () {
                                    //do whatever you want 
                                }
                            }); //end ajax
                            //close dialog
                            $(this).dialog('close');
                        },
                        Cancel: function () {
                            $(this).dialog('close');
                        }
                    },
                    close: function () {
                        $(this).dialog("destroy");
                    }
                }); //end .dialog()
    
                $("#dialog-edit").show();
                $("#dialog-edit").dialog("open");
    
            }) //end edit click
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a form that allows a user to filter a list with by
I have this JavaScript that adds a form field, along with a link to
i have a form that with a link click adds a new for a
I have form that displays several keywords (standard set of choice lists that changes
I have a form that contains a GridView control which is databound to an
I have a form that I would like to style. specifcally I would like
I have a form that searches all rows in a single table (TServices) that
I have a form that is sending in sizes of things, and I need
I have a form that has multiple fields, and for testing purposes is there
I have a form that uses jQuery to submit an ajax post and it

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.