Jump to content

Archived

This topic is now archived and is closed to further replies.

takeiteasy

Alert Dialog Box

Recommended Posts

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
[code]
if (isset($HTTP_GET_VARS['empRef']))
{
$result = mysql_query("DELETE FROM airticketbooking WHERE empRef = '$empRef'",$db_connection) or die(mysql_error());
mysql_close($db_connection);

}

if($result == true)
{
      echo "
'Record Deleted' ";
}
[/code]

Share this post


Link to post
Share on other sites
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
[code]<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;
    }
}
</script>[/code]

Now the link. The following will be what you link will look like:
[code]<a href="delete.php?id=$id" onclick="return confirmDel()">Delete</a>[/code]
Change where it says [i]delete.php?id=$id[/i] 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 [i]return conformDel[/i]. 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.

Share this post


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

Thanks!!!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.