Re: javascript and php

From: Date: Fri, 07 Jul 2000 00:52:30 +0000
Subject: Re: javascript and php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5294@lists.php.net to get a copy of this message
on 7/6/00 12:37 PM, Mathieu Dubé at mat@syspark.com wrote: > Hi, > I'd like to know how(if) can php interprets javascript confirm boxes > > what i want to do is execute a delete query in php on a mysql db if the > confirm > is yes > > If somebody could tell me where i could find info on that topic i'd be > quite happy. No problem. I have done stuff like this. I am not going to check for bugs/sytax or test this, but this should give you a good enough idea on the process to complete it. in your html document <html> <head> <!-- function promptuser(row_id) { //load a page if user clicks okay if (confirm("Are you sure you want to delete this row?") { tempwindow = window.open("delete.php?rowid=" + row_id, "Temp", "directories=no,menubar=no,toolbar=no,resizable=yes,width=100,height=100\"); } } </head> <body> <a href="javascript:promptuser(1);">delete row two</a> <a href="javascript:promptuser(2);">delete row two</a> <a href="javascript:promptuser(3);">delete row three</a> </body> then in delete.php <? //run the delete query; $delete_query = "DELETE FROM foo WHERE row_id = $row_id"; // .. execute query .. // //send the string that will close this temporary window ?> <html> <body onLoad="window.close();"> Row Deleted... Closing window </body></html> <? // script done, EOF Essentially, if user hits 'okay' on the confirm box, a little pop up window shows up, then closes itself after it has executed... works pretty well. -k

« previous php.general (#5294) next »