onclick="return confirm()

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
kgp43
Super Advanced
Super Advanced
Posts: 30
Joined: Sat Jan 10, 2004 5:49 pm

onclick="return confirm()

Post by kgp43 »

Hello,

How do I add this "onClick confirm" to the menu?

<a href="logout.php" onclick="return confirm('Are you sure you want to logout?');">Logout</a>

aI("text=Logout;url=http://www.tackleprices.com/merchant/logout.php;");
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi,

Hmmm... the url parameter is likely to be used regardless of what you run with the clickfunction item property, and you'd end up going to the logout page regardless of the result of the confirm. Might be better to wrap the whole thing in a function that changes the page's location conditionally, depending on the return from the confirm(). Try it like this... put the following function at the top of your menu_data.js file:

Code: Select all

function logout()
{
  if (confirm('Are you sure you want to logout?'))
    location.href="http://websites.milonic.com/tackleprices.com/merchant/logout.php";
}
Then code the Logout menu item like this:

Code: Select all

aI("text=Logout;url=javascript:logout();");
That should do it.

Cheers,

Kevin
kgp43
Super Advanced
Super Advanced
Posts: 30
Joined: Sat Jan 10, 2004 5:49 pm

Post by kgp43 »

I added it all to menu_data.js, isnt that correct?
It dosent seems to work (it just logout without the popup/confirm)
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Can you post a url to the site, so I can take a look? If not, can you post the code from your menu_data.js file here? If you post code, please put all of it between BBCode "code" tags, like so

<b>[code]</b>
your code goes here
<b>[/code]</b>

Cheers,

Kevin
kgp43
Super Advanced
Super Advanced
Posts: 30
Joined: Sat Jan 10, 2004 5:49 pm

Post by kgp43 »

It is working now (uploaded the wrong file)
Thanks for the help :)
Post Reply