Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog Box - OK CANCEL

Status
Not open for further replies.

LucyL

Technical User
Feb 20, 2002
113
0
0
US
Hi,
I am pretty new to javascript and am unsure of the syntax of the following...I have a LOGOUT link that when clicked I want to open a dialog box which asks the user if they are sure they want to exit, and they are given the options of OK or Cancel. Can you do this using javascript? I'm not sure how to do this - any ideas?
Thank you.
 
Use the confirm function. It returns a boolean value so you can use it in an if statment. Here's the structure of how it's used:
Code:
if (confirm("Are you sure?")) {
   alert ("You clicked OK");
}
else {
   alert ("You cliked Cancel");
}

-kaht

banghead.gif
 
Hi

I am pretty new to JS also. But over thelast few weeks with a lot of hard work and extraordinary help from people like Kaht, I have learned a lot.

Here is something I have, that may help you.

--Ram
_________________
<table>

<tr>
<td>
<form action="<%= App.FinalURL %>" method="POST" target="_top">
<input type="submit" value="Run Report">
</form>
</td>
<td>
<form action="<%= App.BackURL %>" method="POST">
<input type="submit" value="Cancel">
<INPUT TYPE="button" VALUE=" Back " onClick="history.go(-1)">


</form>
</td>
</tr>
</table>
 
<form .... onsubmit="return(confirm("are you sure you want to logout?"));"

It's always in the details.
 
I use this on one of my pages for a link not in a form.
Code:
     <SCRIPT LANGUAGE=javascript>
        <SCRIPT LANGUAGE=javascript>
      function logoutYesNo() 
      {
         if ( confirm("Want to log off"))
          {
             top.location.href = "WhereYouWantThem.htm";
          }
      }
    </SCRIPT>
<a style ="cursor:hand; text-decoration : underline;"  onClick = "logoutYesNo()"> Link</a>
Hope this helps



Glen
 
This is great - thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top