using a href (html)tag along with PHP

Posted by dexter on Stack Overflow See other posts from Stack Overflow or by dexter
Published on 2010-03-15T11:04:55Z Indexed on 2010/03/15 11:19 UTC
Read the original article Hit count: 186

Filed under:
|
|
|

i have tried:

<?php include("delete.php") ?>
<?php 

   ....
   ....
   ....

if($result=mysql_query($sql))
                {

                    echo "<table><th>Id</th><th>Name</th><th>Description</th><th>Unit Price</th>";
                    while($row = mysql_fetch_array($result))
                    {
                        echo "<tr><td>".$row['Id']."</td><td>".$row['Name']."</td><td>".$row['Description']."</td><td>".$row['UnitPrice']."</td> 
                        <td><a href='delproduct($row[Id])' onclick = 'return MsgOkCancel()'>Delete</a></td></tr>";
                        echo "<br/>";
                    }
                }
?>

following javascript is in the same page:

<script type="text/javascript" language="javascript">
            function MsgOkCancel() {
                                    if (confirm("Are You Sure You Want to Delete?"))
                                     { return true }
                                    else
                                    {return false}
                                   }
        </script> 

where delproduct is a javascript function in delete.php written like:

<script type="javascript">
function delproduct(Id)
{
    alert('Id '+ Id);
}
<script>

** after ** clicking Delete a okcancel message-box appear asking conformation

** but ** after clicking 'ok' it should execute statements inside delproduct function but it doesn't

it gives error like:

Object Not Found :The requested URL was not found on this server.

what would be the problem?

pls help,

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript