I'm trying to call a javascript function from the onClick event but as far as I know the function isn't being called.
<pre><code>&lt;style type="text/css"&gt;@import url("cstyle.css");&lt;/style&gt;
&lt;style type="text/css"&gt;@import url("style.css");&lt;/style&gt;
&lt;script type="text/javascript"&gt;
function deleteComment(id)
{
    xmlhttp=new XMLHttpRequest();
    xmlhttp.open("GET","deleteComment.php?id="+id,true);
    xmlhttp.send();
}
$(document).ready(function()
{
    deleteComment(id);

});
&lt;/script&gt;
&lt;?php
include_once("pass.php");
include("common.php");

class ComA
{   
    static function reportComment()
    {
        $query = mysql_query("SELECT * FROM comments WHERE Flag =1"); 
        $number=mysql_num_rows($query);
        // number of rows to show per page
        $rowsperpage = 15;
        // find out total pages
        $totalpages = ceil($number / $rowsperpage);
        // get the current page or set a default
        if (isset($_GET['currentpage']) &amp;&amp; is_numeric($_GET['currentpage'])) 
        {
           // cast var as int
           $currentpage = (int) $_GET['currentpage'];
        } 
        else 
        {
           // default page num
           $currentpage = 1;
        } 
        //if current page is greater than total pages...
        if ($currentpage &gt; $totalpages) 
        {
           // set current page to last page
           $currentpage = $totalpages;
        } 
        //if current page is less than first page...
        if ($currentpage &lt; 1) 
        {
           // set current page to first page
           $currentpage = 1;
        }
        //the offset of the list, based on current page 
        $offset = ($currentpage - 1) * $rowsperpage;
        // get the info from the db 
        // while there are rows to be fetched...
        $sql = mysql_query("SELECT * FROM comments WHERE Flag = 1 ORDER BY id DESC LIMIT $offset, $rowsperpage"); 
        ?&gt;
        &lt;div id="count"&gt;
        &lt;div id="title"&gt;&lt;b&gt;Edit Reported Comments&lt;/b&gt;&lt;/div&gt;
        &lt;?php
        if($number==1)
            echo $number . " COMMENT";
        else
            echo $number . " COMMENTS";
        ?&gt;
        &lt;/div&gt;
        &lt;?php
        while ($content = mysql_fetch_assoc($sql))
        {
            ?&gt;
            &lt;div id="delete"&gt;
            &lt;?php $javaid=$content['id']; ?&gt;
                &lt;a href="&lt;?php $_GET['location'] ?&gt;" onClick="deleteComment(&lt;?php echo $javaid ?&gt;)" &gt;&lt;img src="_" onmouseover="_" onmouseout="_"&gt;&lt;/a&gt;
            &lt;/div&gt;
            &lt;div id="comment"&gt;
            &lt;?php
            echo $content['username'] . " &lt;br/&gt; " ;
            ?&gt;
            &lt;div id="timestamp"&gt;
            &lt;?php
            echo "Posted " . $content['date'];      
            ?&gt;
            &lt;/div&gt;
            &lt;?php
            echo $content['comment'];
            ?&gt;
            &lt;/div&gt;
            &lt;div class="greyRule"&gt;&lt;hr /&gt;&lt;/div&gt;
            &lt;?php
        } // end while

        /******  build the pagination links ******/
        // range of num links to show
        $range = 3;
        ?&gt;
        &lt;div id="page"&gt;
        &lt;?php
        // if not on page 1, don't show back links
        if ($currentpage &gt; 1) 
        {
            ?&gt;
            &lt;a href="&lt;?php echo $_GET['location'] ?&gt;&amp;currentpage=1" class="blue"&gt;&lt;&lt; first  &lt;/a&gt;
            &lt;?php
            // get previous page num
            $prevpage = $currentpage - 1;
            ?&gt;
            &lt;a href="&lt;?php echo $_GET['location'] ?&gt;&amp;currentpage=&lt;?php echo $prevpage ?&gt;" class="blue"&gt;&lt; previous  &lt;/a&gt;
            &lt;?php
        }
        // loop to show links to range of pages around current page
        for ($x = ($currentpage - $range); $x &lt; (($currentpage + $range) + 1); $x++)
        {
           // if it's a valid page number...
           if (($x &gt; 0) &amp;&amp; ($x &lt;= $totalpages)) 
           {
              // if we're on current page...
              if ($x == $currentpage)
              {
                 // 'highlight' it but don't make a link
                 echo " &lt;b&gt;$x&lt;/b&gt; "; //needs to be RIGHT ALIGNED
              // if not current page...
              } 
              else 
              {
                 // make it a link
                 ?&gt;
                 &lt;a href="&lt;?php echo $_GET['location'] ?&gt;&amp;currentpage=&lt;?php echo $x ?&gt;" class="blue"&gt; &lt;?php echo $x?&gt;&lt;/a&gt;
                 &lt;?php
              } // end else
           } // end if 
        } // end for                         
        // if not on last page, show forward and last page links        
        if ($currentpage != $totalpages &amp;&amp; $totalpages!=0) 
        {
           // get next page
           $nextpage = $currentpage + 1;        
           ?&gt;
           &lt;a href="&lt;?php echo $_GET['location'] ?&gt;&amp;currentpage=&lt;?php echo $nextpage ?&gt;" class="blue"&gt;  next &gt;&lt;/a&gt;
           &lt;a href="&lt;?php echo $_GET['location'] ?&gt;&amp;currentpage=&lt;?php echo $totalpages ?&gt;" class="blue"&gt;  last &gt;&gt;&lt;/a&gt;
           &lt;?php
        } 
        ?&gt;
        &lt;/div&gt;
        &lt;?php
    }
}
ComA::reportComment();
?&gt;
</code></pre>
