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:02

Retrieving texts of selected items


Poster: davidarnoult
Dated: Friday December 10 2004 - 10:15:46 GMT

Hello,

I am a beginner with this menu and I try to write in my asp page the value of the current selected items.

This can be very effective to show where we are with navigation side bar as texts like

Menu1 > Item1

I have found a global variable _itemRef but when i write it, its value is always -1.

<script language="JavaScript" type="text/JavaScript">
document.write (_itemRef);

</script>

However this menu is great!
Thanks for help !

David


Poster: John
Dated: Friday December 10 2004 - 21:11:56 GMT

Try here, or possibly here, or maybe here.

And thank you for the kind words!

Yes but...


Poster: davidarnoult
Dated: Monday December 13 2004 - 10:51:05 GMT

Thanks for your links but I knew them already...

To write the value of current selected item in a web page, do i need to create an object of the menu first with menu = gmobj("milonic"); and them write -itemRef ??? Or do i need to modify your source codes ?
Why _itemRef is always equal to -1 in my case ?

If I succeed in helping and finding a solution for me, you can be sure I am buying your menu right now!

Thanks

David

here is contents of _mi :
itemRef=-1
0 0,Home,/,,Home,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
1 0,Products,/products/,products,,#006699,#ffffff,#CCCCCC,black,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
2 0,Services,/services/,services,,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
3 0,Success Stories,/success/,success stories,,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
4 0,News and Events,/news/,news and events,,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
5 0,Partners,/partners/,partners,,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
6 0,Company,/company/,company,,#006699,#ffffff,#000000,#ffffff,,#CCCCCC,1,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,20,,,,,,,,center,,,,,,,,,,,,,,,,,,,80,,,,,,,,#000000,solid
7 1,CAD,/products/cad/,cad,,#006699,#000000,#CCCCCC,black,,#CCCCCC,3,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,,,,,,,,,center,,,,,,,,,,,,,,,,,,,,,,,,,,,#000000,solid
8 1,CAM,/products/cam/,cam,,#006699,#000000,#006699,#ffffff,,#CCCCCC,3,10,normal,,Arial,,,black,#CCCCCC,#000000,#ffffff,0,,,,,1,,,,,,,,,center,,,,,,,,,,,,,,,,,,,,,,,,,,,#000000,solid


Poster: bparrish
Dated: Friday December 17 2004 - 17:49:12 GMT

I also have this very same question. How can a page retrieve the information about the menu items/menus which were selected to get to that page? Obviously, that information is available somewhere, because the menu system knows enough to highlight that "path" in the menu tree, should that option be turned on.

"_itemRef" only appears to refer to whatever item is currently, at that split second, being highlighted or moused-over on the current page. What I (and I presume the author of this thread) want is to find out which item was selected (and clicked) which wound us up on the page we're on.

Make sense? Anyone know how to do this?


Poster: kevin3442
Dated: Tuesday December 21 2004 - 23:44:47 GMT

Hi David,

The likely reason that you're seeing _itemRef = -1 is that you are checking it after a new page loads.

As bparrish surmised, _itemRef is a global variable whose value constantly changes to reflect the most recent menu item pointed to. If you click on a menu item, and that item's url takes you to a different page, then that page loads the menu code anew. As a result, _itemRef will be -1 (its starting value) because no menu items have been pointed to yet on the new page.

So, what you're really looking for is the _itemRef of the last item pointed to on the previous page (that would work only if the new page loads the same menu_data.js as the previous page). So, how do you get the _itemRef from the previous page to the new page? (1) You could pass the _itemRef from one page to the next as a parameter in the url. The new page would then use a small javascript to extract the passed parameter. (2) You could use a hidden frame to store the value; it would be available from any new page in the visible frame. (3) You could store the _itemRef in a cookie, but the usual limitations of cookies would apply (e.g., it wouldn't work if the user had cookies disabled). Whatever method you use, the value you pass to the new page could then be used as an index into the menu system's _mi[] array, to extract the value of the menu item's text property.

Another approach, sort of suggested by bparrish's observation about the menu's pagematch capability, would be to loop through the menu items until you find the item whose url parameter corresponds to the current page's url. That way, you figure out the item that was (probably) responsible for getting you to the current page. That should be do-able with javascript, but you'd want to make sure to use unambiguaous urls, so that each url is not likely to be confused with multiple pages.

If you want to try any of these solutions, but aren't sure how to go about it, give a holler and I'll see if I can whip something up.

Cheers,

Kevin


Poster: bparrish
Dated: Thursday December 23 2004 - 20:35:41 GMT

For those who might be curious, I accomplished this by adding various things to the end of the URL, showing where in the menu tree each link was.

So, for instance, for the top level, I add "level1=thisitem". For the next level down, I add "leve1=topitem&level2=thisitem". For the third layer down, "level1=topitem&level2=level2item&level3=thisitem".

Then I just pick up whatever "levelx" parameters get passed to the next page, and figure it out thuswise.

(Passing the "_itemRef" thing might have been a cleaner, simpler way of doing this, but I wasn't smart enough to figure that out beforehand.)

Thanks for your tips


Poster: davidarnoult
Dated: Monday January 3 2005 - 8:54:59 GMT

Hello guys and first Happy New Year !!!! :D

To answer to Kevin and bparrish, I suggest to use, to my opinion, what is the cleaner way: with -itemRef stored in a javascript variable along the pages, method #1 described by Kevin.

However, I am not a javascript expert, and I would be very happy if somenone could give me some help to start this function...

I have to deliver my new web site to my customers end of january, I would be very happy to show them with this great menu with this functionality. If I succeed in doing this quickly, this will let me some time to order a licence of this great tool.

Thanks guys for your contribution, this forum is very helpful.

David, webmaster from France
d.arnoult __at__ topsolid.com

Giving a holler


Poster: davidarnoult
Dated: Thursday January 20 2005 - 10:44:18 GMT

Hi Kevin !

I try to use method #1 as you explain previously but I cannot succeed in reading _itemRef value to pass it on url...

Any hints ?

Thanks a lot

David


Poster: kevin3442
Dated: Friday January 21 2005 - 1:23:37 GMT

Hi David,

Sorry I never got back to this thread. Sort of forgot about it :oops:

I worked up a sample, but I'm having some trouble posting it to the support domain right now. I'll see about putting it somewhere else. Might have to wait until tomorrow.

Cheers,

Kevin


Poster: kevin3442
Dated: Friday January 21 2005 - 1:40:46 GMT

Hi again David,

I posted a sample similar to what I think you want to do here. You can check it out on line and also download the sample from there.

If you have questions, I'll be back tomorrow.

Cheers,

Kevin

Thanks Kevin


Poster: davidarnoult
Dated: Friday January 21 2005 - 13:31:16 GMT

Hi Kevin,

This is what I was looking for ! Wondeful!
Thanks very much for your great help, this is excellent.

I am just wondering if it would be possible to a link on each itemref using the url specified in the menu, in order to navigate also through these links... :D

Like :
Item1 > SubItem2
<A href='url1'>Item1</A>
<A href='url2'>SubItem2</A>

Any idea to easily do that from your work ?

Thanks again and anyway without the link this is very good.

David From France

Re: Retrieving texts of selected items


Poster: Ruth
Dated: Saturday June 13 2009 - 20:16:38 BST

Hi,

Kevin isn't here anymore :( He did a lot of absolutely marvelous things but now there is no one who volunteers here with js function knowledge and in depth study of the menu programming. I was looking at your data file and Kevin's breadcrumb creation t to see if I could figure out anything that might be what would stop the page properties from working and the only thing I can figure is that the page url doesn't actually show a match anymore. I mean this is what I get
Code:
1_1_1.html?9
as the url we reach when clicking, but the url parameter is actually
Code:
javascript:mm_openUrl('1_1_1.html')
So, maybe you can use something like regexmatch in the aI also, and see if that works,

Code:
aI("text=1.1.1;url=javascript:mm_openUrl('1_1_1.html');clickfunction=mm_getSelectionSequence();regexmatch=1_1_1.html;");


You would have to test this since I have no idea if it will work and no way to test it. I think what that regexmatch does is to give you a 'text' match for the url, but since that parameter is using javascript:mm_openUrl it may not work.

Ruth

Re: Retrieving texts of selected items


Poster: John
Dated: Tuesday June 23 2009 - 7:03:39 BST

Note that the code Kevin wrote is over 4 years old, and was not written for the current version of the menu. My guess is, because of the extensive changes to the menu code in the last 4+ years, Kevin's code is no longer relevant.

Re: Retrieving texts of selected items


Poster: Dagonae
Dated: Saturday June 13 2009 - 12:45:42 BST

Hi Kevin... I tried your breadcrumb code, and it works like a charm. Thank you. I do notice however that once implemented, the active colours of the links are lost:

1) See http://www.designdrake.com/tvp/crumbs/index.html
2) menu path 1) Topic Here > 1.1 > 1.1.1
3) You will note the breadcrumb, but the menu has lost its active colour.

As a comparison, try the menu path 1) Topic Here > 1.1 > 1.1.2

This example does not have the breadcrumb code and holds its active links. Can you suggest a solution?

Many Thanks, Dagonae