Jump to content

ALERT


jwk811

Recommended Posts

When you create the confirmation dialog box using the confirm function you store it in a variable:
[code]myConf = confirm('my confirmation message here');[/code]

Now the variable myConf will hold the value of true if the user clicks the OK Button, or false if the user clicks the cancel/close button. So to see what button they chose you use a if statement like so:
[code]if(myConf) {
    // TRUE - OK Button
} else {
  // FALSE - Cancel/Close Button
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/27297-alert/#findComment-126626
Share on other sites

You'll need to add that code into a function like so:
[code]function confirmLogout()
{
    confirmLogout = confirm('Are you sure you want to logout?');

    if(confirmLogout) {
return true;
    } else {
return false;
    }
}[/code]

Then for your log out link, it'll be like this:
[code]<a href="logout.php" onclick="return confirmLogout()">Logout</a>[/code]

Now what it will do is if you click the link it'll wait until your press the OK or Cancel button on the confirmation dialogue box that will popup. If you press the Ok button it will then continue on to logout.php or whatever the destination is for the link. If you click the Cancel button or close the confirmation dialogue box it will do nothing and keep you on the same page.
Link to comment
https://forums.phpfreaks.com/topic/27297-alert/#findComment-126775
Share on other sites

Archived

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

×
×
  • Create New...

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.