Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Sat Nov 19, 2005 2:39 pm Reply with quote

I would like to find a function I could use throughout my module for deletion of records. I simple:

ConfirmDelete('Are you sure you want to delete this record')

I found some in javascript but am unsure how to modify them. My op=delwhatever gets called from different pages and then are sent to my editwhatever.php page via the case statement on my index.php page.

Example:

Code:
<td align="center" width="15%"><a href="modules.php?name=<?php echo $module_name ?>&op=delUnit&id=<?php echo $id ?>">Delete</a><p>


then my index that tells it where to go.

Code:
case "delUnit":

      @include_once("modules/$module_name/admin/editunit.php");
       break;


Then my editunit page that deletes it.

Code:
if ($op == "delUnit") {

$unit_id = intval($_GET['id']);
$result2 = $db->sql_query("DELETE FROM " . $prefix . "_milpacs_units WHERE unit_id ='$id'");
   Header("Location: /modules.php?name=MILPACS&file=admin");
   die();


Where and how could I implement these functions I found.

Code:


function verify(){
msg = "Are you sure you want to delete this record from the database?";
//all we have to do is return the return value of the confirm() method
return confirm(msg);
}


//insert this in the submit button or link
//onclick=" return verify()"

then you could just use your original php code like this:

echo("<A HREF='delete.php?id=$id' onclick=\"return verify()\">DELETE</A>");


And another I found


Code:
Just put this little javascript near the top of your page somewhere:



function ConfirmDelete(confirmtext, url) {
if(confirm(confirmtext)) {
location.href=url;
} else {
return false;
}
}


and then make your links something like this:

<a href=\"#\" onclick=\"javascript:ConfirmDelete('Are you sure you want to delete this entry','delete.php?id=$id');\">Delete</a>
 
View user's profile Send private message Visit poster's website ICQ Number
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Feb 25, 2006 3:58 pm Reply with quote

Donovan,

You have probably resolved this by now, but I wanted to check anyway.
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©