Jump to content


Alert Dialog Box

  • Please log in to reply
3 replies to this topic

#1 takeiteasy

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 10 May 2006 - 08:02 AM

can i ask if there's php code for displaying an alert dialog box?if there is. can anyone teach me how to code please?

i'm doing a delete function and i want to prompt the user if they really want to delete the record.
here is my delete code
if (isset($HTTP_GET_VARS['empRef']))
$result = mysql_query("DELETE FROM airticketbooking WHERE empRef = '$empRef'",$db_connection) or die(mysql_error());


if($result == true)
      echo "
'Record Deleted' ";

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 May 2006 - 10:56 AM

There is no way to do it in PHP. But you can with javascript. What you'll want to do is sometying like this:

Place this code just before the <head> tags on your script
<script type="text/javascript">
function confirmDel()
    var del = confirm("Are you sure you wish to continue?\n\nClick Ok to continue");
    if (del) {
        return true;
    } else {
        return false;

Now the link. The following will be what you link will look like:
<a href="delete.php?id=$id" onclick="return confirmDel()">Delete</a>
Change where it says delete.php?id=$id to where you actually send the user and dont forget to send the and id over the url so mysql deletes the correct data from mysql.

NOte the what how the code works is the onclick attribute. Notice that is says return conformDel. What that does is it will only go to the delete.php page if and onlu of the confirmDel function returns true, otherwise it will not go any where, and thats how you create simple confirm box.

#3 takeiteasy

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 11 May 2006 - 02:55 AM

oh! thank you so much wildteen88!! This really helps me alot!!

#4 texhead

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 30 May 2006 - 08:43 PM

wildteen88! I have been looking for this simple explanation for a week now, all the others did not get down to the basics.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users