Re: php and javascript?
| From: | Adam Royle | Date: | Mon, 22 Jul 2002 12:46:46 +0000 |
| Subject: | Re: php and javascript? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-20705@lists.php.net to get a copy of this message | ||
Just reiterating over what the others have said (plus expanding), and just a bit cleaner.
<SCRIPT language="JavaScript">
<!--
function deleteRecord(recordName, recordID)
{
if (confirm("Do you really want to delete "+ recordName+"?"){
window.location = "/delete.php?id="+recordID;
}
}
//-->
</SCRIPT>
<!-- and your html will be like this (obviously change your var names as per your script -->
<A HREF="javascript:deleteRecord('<?= $recordName ?>','<?= $recordID ?>');"><?= $recordName ?></A>
HTH,
Adam.
Hi, Here is what I wanted to achieve, I want to get a confirmation box pop up when user click on the delete link of the webpage(displays the contents got from mysql database). I know we can do it in javascript easily, but my question is: 1st, a common javascript confirmation will be like this: <SCRIPT language="JavaScript"> <!-- function go_there() { var where_to= confirm("Do you really want to go to this page??"); if (where_to== true) { window.location="http://detination"; } else { window.location="http://original"; } } //--> </SCRIPT> <A HREF="javascript:go_there()">New Page</A> my question is how to integrate the javascript with php, the sample delete link will be something like: http://localhost/index.php?id=1 ,and the id number(in this case:1) is from database: (<a href=delete.php?".$row["id"].">) 2nd is there a better way to write pure php code to get a confirm window pop up once i clicked on delete link? Thanks and Good day. Bo