Note that there are some explanatory texts on larger screens.

plurals
  1. PODeleting a row from dynamic table when click on image
    text
    copied!<p>I am working on a PHP/MySQL grid that list two little icons, one is expected to delete the actual register and remove the row and the other is supposed to redirect the user to another page opening the details of the selected register. This is how my code looks like:</p> <p>PHP:</p> <pre><code>$output .='&lt;tr id="'.$id.'"&gt;'; $output .='&lt;td align="center"&gt;'.$expiration_date.'&lt;/td&gt;'; $output .='&lt;td&gt;'.$title.'&lt;/td&gt;'; $output .='&lt;td&gt;'.$title_pt.'&lt;/td&gt;'; $output .='&lt;td align="center"&gt;'.$last_update.'&lt;/td&gt;'; $output .='&lt;td align="center"&gt;'.$active_pack.'&lt;/td&gt;'; $output .='&lt;td align="center" class="icon_grid"&gt;&lt;a id="edit" title="Open the register." href="special_pack_open.php?id='.$id.'"&gt;&lt;img src="images/Write2.gif" width="16" height="16" /&gt;&lt;/a&gt;&lt;/td&gt;'; $output .='&lt;td align="center" class="icon_grid"&gt;&lt;a id="delete" title="Delete the register." href="#"&gt;&lt;img src="images/Trash.gif" width="16" height="16" /&gt;&lt;/a&gt;&lt;/td&gt;'; $output .='&lt;/tr&gt;'; </code></pre> <p>JQuery:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('table tr[id]').click(function(){ $(this).closest("tr").remove(); var obj = $(this); $.ajax({ type: "POST", url: 'delete_package.php', data: { pk_id: obj.attr("id")}, dataType: "json", success: function(data, evt) { if (data.success == "true") { alert('The record has been deleted successfuly!'); } else { alert('error'); } } }) }) }) &lt;/script&gt; </code></pre> <p>Everything is working very good. When I click in the Trash.gif, it deletes the register and remove the row. The thing is when I click on the Write2.Gif (second link) where it is supposed to go to the next page, it does the same action as delete does! How can I change my JQuery code to make it understand that only one link is dedicated to delete the register?</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload