PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dman779
Forum Newbie
Posts: 6 Joined: Wed Jan 21, 2009 6:47 pm
Post
by dman779 » Wed Jan 21, 2009 6:51 pm
I need help implementing a confirm delete pop up for a delete function on my script. Here is the php code:
Code: Select all
echo '<td align="center">[<a href="cross_check.php?userID='.$a2['id'].'" class="Ab">Cross Check</a>][<a href="support_reply.php?start_message=new&user_id='.$a2['id'].'#newMess" class="Ab">Message User</a>][<a href="?action=Delete&&id='.$a2['id'].'" class="Ab">Delete</a>]/[<a href="?action=View&&id='.$a2['id'].'" class="Ab">Edit</a>]/'.$Link.'</td>
Can someone please tell me what to add so that when the function delete is clicked a javascript or other pop up comes up and confirms that i want to delete this user.
Thank You!
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Wed Jan 21, 2009 8:20 pm
Code: Select all
function deleteIt(what)
{
if(confirm("are you sure you want to delete "+what))
// do stuff
}
mattpointblank
Forum Contributor
Posts: 304 Joined: Tue Dec 23, 2008 6:29 am
Post
by mattpointblank » Thu Jan 22, 2009 3:08 am
Just remember that if the user has javascript disabled, they'll get no warning...
Sindarin
Forum Regular
Posts: 521 Joined: Tue Sep 25, 2007 8:36 am
Location: Greece
Post
by Sindarin » Thu Jan 22, 2009 8:36 am
I prefer to do it by showing a div,
Delete link goes to index.php?action=confirmdelete&id=$entryid, that shows a div over the entry with Yes and No links.
Yes has link index.php?action=delete&id=$entryid which removes the entry from the database while No just goes to index.php.
dman779
Forum Newbie
Posts: 6 Joined: Wed Jan 21, 2009 6:47 pm
Post
by dman779 » Thu Jan 22, 2009 2:42 pm
Thanks for your help everyone, I ended up doing this with the code:
adding this script to the code at the top of my page:
Code: Select all
<script type="text/JavaScript">
function confirmDelete()
{
return confirm("Are you sure you want to delete this user?");
}
</script>
this is the code that displays functions for my users on my dashboard. I ended up adding
to my original code to call the function. The final code is below.
Code: Select all
echo '<td align="center">[<a href="cross_check.php?userID='.$a2['id'].'" class="Ab">Cross Check</a>][<a href="support_reply.php?start_message=new&user_id='.$a2['id'].'#newMess" class="Ab">Message User</a>][<a href="?action=Delete&&id='.$a2['id'].'" onclick="return confirmDelete();" class="Ab">Delete</a>]/[<a href="?action=View&&id='.$a2['id'].'" class="Ab">Edit</a>]/'.$Link.'</td></tr>';