Pradeep_Chinna Posted August 3, 2013 Share Posted August 3, 2013 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> Quote Link to comment https://forums.phpfreaks.com/topic/280784-how-to-get-popup-after-clicking-delete-link/ Share on other sites More sharing options...
Solution jcbones Posted August 3, 2013 Solution Share Posted August 3, 2013 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/280784-how-to-get-popup-after-clicking-delete-link/#findComment-1443372 Share on other sites More sharing options...
Pradeep_Chinna Posted August 4, 2013 Author Share Posted August 4, 2013 wow..!!Thank you very very much jcbones Quote Link to comment https://forums.phpfreaks.com/topic/280784-how-to-get-popup-after-clicking-delete-link/#findComment-1443396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.