Jump to content

how to get popup after clicking delete link ?


Go to solution Solved by jcbones,

Recommended Posts

PLEASE HELP ME OUT....

 

Following code deleting my data without getting any popup window...
 

this is link code:

 

echo ("<td><a href=\"delete.php?number=$row[iD]\" onclick=\"myFunction();\">Delete</a></td></tr>");

 

 

this is function code:

 

<script type="text/javascript">
function myFunction()
{
var y=window.confirm("Do you really want to DELETE ?");
if(y==true)
{
 
<?php
$order = "DELETE FROM budget WHERE ID='$no'";
$result=mysql_query($order);
if(isset($result))
{
print "submitted successfully "; echo "<br/>";
printf ("Updated records: %d\n", mysql_affected_rows()); echo "<br/>"."<br/>";
echo "<br/>";
  echo "want to DELETE one more?"; echo " ";
  echo "<a href=\"editstart.php\">Click here</a>"; echo "<br/>"; echo "OR"; echo "<br/>";
  echo "<a href=\"home.php\">Click here to go to HOMEPAGE</a>"; echo "<br/>";
}
 
?>
}
else
{
document.write("cancel");
window.location("#");
}
}
</script>
  • Solution

Javascript is like the Mailbox, and PHP is like the Power company.  You are asking the Mailbox to keep the lights on.  Since Javascript is a client side scripting language, and PHP is a server side scripting language, they don't understand each other.  They need something to help them out.

In comes the Mail Truck, or HTTP protocol.  You must send the relevant data from the client to the server (javascript to PHP), in order to get a proper return.

 

Your link should be:

 

echo ("<td><a href=\"delete.php?number=$row[ID]\" onclick=\"return confirm('Do you really want to DELETE ?');\">Delete</a></td></tr>");

 

Your delete code should run on delete.php, using proper sanitation and validation on your $_GET parameters.  You can use a header() to re-direct back to your listings, or you can use AJAX to push the url to the delete script "behind the scenes".  In todays HTML world, the possibilities are nearly endless.  HAVE FUN!!!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.