mukund
mukund

Reputation: 327

customized javascript confirmation box

enter image description hereI have customized confirmation box....When I press the logout the box is displayed...If cancel is pressed the box is closed the control remains in the same page...When yes is pressed ,logout has to take place....For me,cancel is working fine...But when user presses yes, there is no response....Could anyone help me...Thanks in advance...

My code:

<s:a href="logout" cssClass="planTabHeader" id="logoutId"> <img src="../../KY/images/common/header/lock.png" alt="logout" style="border: none;background-color: transparent;" /> &nbsp;Log out</s:a>

javascript:

<script type = "text/javascript" > 
$(document).ready(function () {
    $($('#logoutId')).click(function (event) {


        var msg = "";
        var buttons = {};
        msg = "Are you sure you want to logout?";

        buttons["Yes"] = doLogout;

        buttons["Cancel"] = closeDialog;
        if (msg != "") {

            showDialog(buttons, "cancelConfirm", msg, "dialogNormal",
                "Confirmation", 470);

        }
        return false;
    });
});

function doLogout() {
    document.getElementById("logoutId").href = "logout";
}

function closeDialog() {
    /* alert("action is closeDialog"); */
    $("#cancelConfirm").dialog("close");
    $("#cancelConfirm").dialog("destroy");
} 
</script>

Upvotes: 0

Views: 752

Answers (1)

TommyBs
TommyBs

Reputation: 9646

Expanding on my comment above maybe your function should be

   function doLogout() {
window.location = "/logout"; // not sure on your url structure
  }

Upvotes: 1

Related Questions