Javascript deleting from database/fading the table row away
<p>First of all i didn't know how to specify the title sorry for that.</p>

<p>I have a pretty messy code but basically this is what it should do.
When the delete button is pressed the whole tr should fade away. Currently only the last td with the button in it fades away. I tried replacing the a at</p>

<pre><code>$('a').click(function(){
</code></pre>

<p>with tr. But when i do that the row will dissapear but it wont delete in the database.
Does anyone know a sollution? Thanks in advance</p>

<p>ps: Sorry for my english and the badly displayed coded.</p>

<pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;link rel="stylesheet" href="style.css" /&gt;
    &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        $('document').ready(function(){
        $('a').click(function(){
        var del_id = $(this).attr('id');
        var parent = $(this).parent();
        $.post('delete.php', {id:del_id},function(data){
        parent.slideUp('slow', function() {$(this).remove();});
        });
        });
        });
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id="content1"&gt;&lt;/div&gt;
    &lt;table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th class="nosort"&gt;&lt;h3&gt;ID&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Merk&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Type&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Imei&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Serienummer&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Kleur&lt;/h3&gt;&lt;/th&gt;
                &lt;th&gt;&lt;h3&gt;Locatie&lt;/h3&gt;&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;

        &lt;tbody&gt;
            &lt;?php
                include 'Includes/database_connection.php';
                $sql = "select *
                        FROM units";
                $result = mysql_query($sql,$con);       
                while($row = mysql_fetch_assoc($result)){
                echo "&lt;tr&gt;";
                echo "&lt;td&gt;{$row['id']}&lt;/td&gt;&lt;td&gt;{$row['merk']}{$row['type']}{$row['imei']}{$row['serienr']}{$row['kleur']}{$row['locatie']}&lt;a href=\"javascript:return(0);\" id=\"{$row['id']}\"&gt;&lt;img src=\"images\delete_icon.gif\" height=\"12px\" width=\"12px\"/&gt;&lt;/a&gt;&lt;/td&gt;";
                echo "&lt;/tr&gt;";
                }       
                                while($row = mysql_fetch_array($result)) {

                                echo "&lt;tr&gt;";
                                echo "&lt;td&gt;".$row['id']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['merk']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['type']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['imei']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['serienr']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['kleur']."&lt;/td&gt;";
                                echo "&lt;td&gt;".$row['locatie']."&lt;/td&gt;";
                                ?&gt;
                                &lt;td&gt;&lt;a href="#" onclick="window.open('test1.php?id=&lt;?php echo $row['id']; ?&gt;', 'newwindow', 'width=400, height=600'); return false;"&gt;&lt;img src="images/gtk-edit.png"/&gt;&lt;/a&gt;&lt;/td&gt;

                                &lt;?php

                                echo "&lt;/tr&gt;";
                            }


                            ?&gt;
                        &lt;/tbody&gt;
                  &lt;/table&gt;
        &lt;div id="controls"&gt;
            &lt;div id="perpage"&gt;
                &lt;select onchange="sorter.size(this.value)"&gt;
                &lt;option value="5" selected="selected"&gt;5&lt;/option&gt;
                    &lt;option value="10" &gt;10&lt;/option&gt;
                    &lt;option value="20"&gt;20&lt;/option&gt;
                    &lt;option value="50"&gt;50&lt;/option&gt;
                    &lt;option value="100"&gt;100&lt;/option&gt;
                &lt;/select&gt;
                &lt;span&gt;Weergeven per pagina&lt;/span&gt;
            &lt;/div&gt;
            &lt;div id="navigation"&gt;
                &lt;img src="images/first.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" /&gt;
                &lt;img src="images/previous.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1)" /&gt;
                &lt;img src="images/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" /&gt;
                &lt;img src="images/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" /&gt;
            &lt;/div&gt;
            &lt;div id="text"&gt;Pagina &lt;span id="currentpage"&gt;&lt;/span&gt; van &lt;span id="pagelimit"&gt;&lt;/span&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript"&gt;
      var sorter = new TINY.table.sorter("sorter");
        sorter.head = "head";
        sorter.asc = "asc";
        sorter.desc = "desc";
        sorter.even = "evenrow";
        sorter.odd = "oddrow";
        sorter.evensel = "evenselected";
        sorter.oddsel = "oddselected";
        sorter.paginate = true;
        sorter.currentid = "currentpage";
        sorter.limitid = "pagelimit";
        sorter.init("table",1);
      &lt;/script&gt;
    &lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>And my process file</p>

<pre><code>&lt;?php
include 'Includes/database_connection.php';
$id = $_POST['id'];
$safeid = mysql_real_escape_string($id);
$query = mysql_query("delete from units where id=$id", $con);
?&gt;
</code></pre>
