Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:15

onclick="return confirm()


Poster: kgp43
Dated: Saturday August 14 2004 - 21:02:05 BST

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;");


Poster: kevin3442
Dated: Sunday August 15 2004 - 3:54:40 BST

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:
function logout()
{
  if (confirm('Are you sure you want to logout?'))
    location.href = "http://www.tackleprices.com/merchant/logout.php";
}

Then code the Logout menu item like this:
Code:
aI("text=Logout;url=javascript:logout();");

That should do it.

Cheers,

Kevin


Poster: kgp43
Dated: Sunday August 15 2004 - 10:01:12 BST

I added it all to menu_data.js, isnt that correct?
It dosent seems to work (it just logout without the popup/confirm)


Poster: kevin3442
Dated: Sunday August 15 2004 - 10:20:27 BST

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


Poster: kgp43
Dated: Sunday August 15 2004 - 10:40:02 BST

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