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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:19:07+00:00 2026-05-20T11:19:07+00:00

Here’s my goal: have a table of data with edit/delete buttons. The edit buttons

  • 0

Here’s my goal: have a table of data with edit/delete buttons. The edit buttons open a modal dialog with the form pre-populated with the details for the appropriate row. I have had trouble getting the ajax to work to actually fill out the form on the fly, so I’m just opening an edit page inside the modal and passing the id. It works great…for the first edit button. Nothing at all happens on subsequent edit buttons. I’m at a loss. I’m no javascript or jquery expert, but have googled away and haven’t found anything to handle my situation (or that I could successfully adapt). I’m pretty sure it involves .each and/or .sibilngs, but I’m not sure how to implement. Here is all code, as it stands, other than styles and some PHP for validating users:

<link type="text/css" href="js/css/start/jquery-ui-1.8.9.custom.css" rel="stylesheet" />    
<!--<script type="text/javascript" src="js/js/jquery-1.4.4.min.js"></script>-->
<script type="text/javascript" src="js/jquery-1.5.1rc1.js"></script>
<script type="text/javascript" src="js/js/jquery-ui-1.8.9.custom.min.js"></script>

<script type="text/javascript">
//table highlights & such
$(document).ready(function() {
$(".striped tr").mouseover(function() {
$(this).addClass("highlight");
});
$(".striped tr").mouseout(function() {
$(this).removeClass("highlight");
});
$(".striped tr").toggle(function() {
$(this).addClass("selected");
}, function () {
$(this).removeClass("selected");
});
$(".striped tr:nth-child(odd)").addClass("odd");
});

$(function(){
    $('#edit_number').dialog({  autoOpen: false,width: 400,height: 500, modal:true, open: function() {
        var editqs = 'process.php?action=edit_num_form&id=' + $(this).data('num_id') + '&rep_id=<?php echo $rep_id ?>';
        $("#edit_number").load(editqs);
        }
    });

$('.edit_number_link').live('click', function() {
    var id = $(this).closest('tr').data('id');
    $("#edit_number").data('num_id', id).dialog('open');
    return false;
});


});

</script>
</head>

<body>
<table style="border: 1px solid #000;" border=1 cellpadding=0 cellspacing=0 class="striped">
  <thead>
    <tr style="background-color: #ccc;">
        <th align=left width=100>Name</th>
        <th align=left width=100>External</th>
        <th align=left width=100>Internal</th>
        <th align=left width=50>Options</th>
        <th align=left width=50>Hours</th>
        <th align=left width=150>Notes</th>
        <th colspan=2>&nbsp;</th>
    </tr>
  </thead>
<?php
//db connection stuff    
while($row = mysql_fetch_array($result))
  {
    $name = $row['name'];
    $external = $row['external'];
    $internal = $row['internal'];
    if ($internal == "")
      $internal = "&nbsp;";
    $options = $row['options'];
    if ($options == "")
      $options = "&nbsp;";
    $hours = $row['hours'];
    if ($hours == "")
      $hours = "&nbsp;";
    $comments = $row['comments'];
    if ($comments == "")
      $comments = "&nbsp;";
    $id = $row['id'];

  echo "<tr data-id=".$id."><td>" . $name . "</td>";
  echo "<td>" . build_link($external,$rep_id, "ext", $userfound) . "</td>";
  echo "<td>" . $internal . "</td>";
  echo "<td>" . $options . "</td>";
  echo "<td>" . $hours . "</td>";
  echo "<td>" . $comments . "</td>";
  //echo "<td><a href='process.php?action=edit_num_form&id=" . $id . "&rep_id=".$rep_id."' title='Edit'><img src='edit.png' alt='Edit' border='0'></a></td>";
  echo "<td><a href='#' title='Edit' class='edit_number_link'><img src='edit.png' alt='Edit' border='0'></a></td>";
  echo "<td><a href='process.php?action=delete_num&id=" . $id . "&rep_id=".$rep_id."' title='Delete'><img src='delete.png' alt='Delete' border='0'></a></td>";
  //echo "<td><a href='?action=delete' class='delete'>Delete</a></td>";
  echo "</tr>";
  }
echo "</table>";
mysql_close($con);
?>

<div id="edit_number" title="Edit Number">
</div>
</body>

</html>

So ideally, I can retrieve my data from each edit button to load the form in a real modal (not an external page), but at a minimum, need the additional instances to work.

Any help would be 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-05-20T11:19:07+00:00Added an answer on May 20, 2026 at 11:19 am

    Since I can’t see the entire code set…Is #edit_number_link inside of #edit_number? If so, you’ll need to use jQuery’s live() method to bind the event as the DOM is being updated after the initial page load.

    Also, you don’t need the attr('data-id') as jQuery now will map these attributes to the .data() method. You need .data('id') to retreive this value.

    Another thing is that you’re using an ID when you should be using a class. IDs are suppose to be unique and only used once. You should change #edit_number_link to a class, .edit_number_link. I’m not sure which container is #edit_number but I am assuming that there is just one.

    $('.edit_number_link').bind('click', function() {
        var id = $(this).closest('tr').data('id');
        $("#edit_number").data('num_id', id).dialog('close').dialog('open');
        return false;
    });
    

    UPDATE Aftering seeing the code and actually trying it out on jsfiddle, I found that what is happening is that when you click on the other edit links, the dialog window is already open and doesn’t fire it’s open callback. What you need to do it update the code so that the dialog is closed before you open it. My code above is updated to include .dialog('close'). Also, I’ve changed live back to bind as it’s not needed in this case.

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

Sidebar

Related Questions

Here are the tables I have: Table A which has entries with item and
Here's a problem I ran into recently. I have attributes strings of the form
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),
Here is an example: I have the generic type called Account. I wish to
Here is the problem that I am trying to solve. I have two folders

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.