Menu Problem - JavaScript

They have: 51 posts

Joined: Dec 2002

Got a bit of a problem..

====Original Code====
BLANK_IMAGE="img/b.gif";
//keywords
var code="code";var url="url";var sub="sub";
//styles
var color = {"border":"#666666", "shadow":"#DBD8D1", "bgON":"white","bgOVER":"#B6BDD2"};
var css = {"ON":"clsCMOn", "OVER":"clsCMOver"};
var STYLE = {"border":1, "shadow":2, "color":color, "css":css};
//items and formats
var MENU_ITEMS =
[
{"pos":[10,10], "itemoff":[21,0], "leveloff":[21,0], "style":STYLE, "size":[22,150]},
{code:"Sizing", url:"sizing/index.html", "target":"mainFrame"},
{code:"Positioning", url:"positioning/index.html", "target":"mainFrame"},
// {code:"Popup", url:"popup/index.html", "target":"mainFrame"},
// {code:"Frames support", url:"frames/index.html", "target":"_blank"},
{code:"Unlimited levels", url:"levels/index.html", "target":"mainFrame"},
{code:"Styles", url:"styles/index.html", "target":"mainFrame"},
{code:"Borders and shadow", url:"bordersandshadow/index.html", "target":"mainFrame"},
{code:"Multiple menus", url:"multiple/index.html", "target":"mainFrame"},
{code:"Download Now!", url:"http://javascript.cooldev.com/files/COOLjsMenu.zip", "format":{"itemoff":[30,0]}},
{code:"Order Now! (only $29)", url:"http://javascript.cooldev.com/registration.shtml?id=160728", "format":{"itemoff":[21,0]}},
{code:"Other COOL Scripts!", "format":{"itemoff":[30,0]},
sub:[
{"leveloff":[-15,145], "itemoff":[-21,0]},
{code:"COOLjsMenu PRO", url:"http://javascript.cooldev.com/scripts/coolmenupro/", "target":"_top"},
{code:"COOLjsTree", url:"http://javascript.cooldev.com/scripts/cooltree/", "target":"_top"},
{code:"COOLjsTree PRO", url:"http://javascript.cooldev.com/scripts/cooltreepro/", "target":"_top"},
]
},
];

====My Attempt====
BLANK_IMAGE="img/b.gif";
//keywords
var code="code";var url="url";var sub="sub";
//styles
var color = {"border":"#666666", "shadow":"#DBD8D1", "bgON":"white","bgOVER":"#B6BDD2"};
var css = {"ON":"clsCMOn", "OVER":"clsCMOver"};
var STYLE = {"border":1, "shadow":2, "color":color, "css":css};
//items and formats
var MENU_ITEMS =
[

{"pos":[10,200], "itemoff":[0,69], "leveloff":[21,0], "style":STYLE, "size":[15,100]},
{code:"Paramilitaries", sub:[
{},

{code:"Bounty Hunters", "format":{"leveloff":[0,105]}, sub:[
{},

{code:"BHA", "format":{"leveloff":[0,150]}, sub:[
{code:"Testing", "format":{"leveloff":[100,300]}, sub:[

]}
]}
]}
]}

];

When I preview it on the page only 'BHA' comes up, not 'Testing'

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I'm not familiar with this script in particular, but try this out anyway...

That "Testing" node doesn't have any submenus, so instead of having a blank sub:[], just remove that part.

You'll just want code, format, url, and target, if it's a terminating menu item.

Not sure if that'll work. It might help if you posted the rest of the code or the url to the script. Also, did the script come with a readme or other instructions?

Try it out anyway, and post back with the result. Wink

They have: 51 posts

Joined: Dec 2002

====Changed Code====
BLANK_IMAGE="img/b.gif";
//keywords
var code="code";var url="url";var sub="sub";
//styles
var color = {"border":"#666666", "shadow":"#DBD8D1", "bgON":"white","bgOVER":"#B6BDD2"};
var css = {"ON":"clsCMOn", "OVER":"clsCMOver"};
var STYLE = {"border":1, "shadow":2, "color":color, "css":css};
//items and formats
var MENU_ITEMS =
[

{"pos":[10,200], "itemoff":[0,69], "leveloff":[21,0], "style":STYLE, "size":[15,100]},
{code:"Paramilitaries", sub:[
{},

{code:"Bounty Hunters", "format":{"leveloff":[0,105]}, sub:[
{},

{code:"BHA", "format":{"leveloff":[0,150]}, sub:[
{code:"Testing", "format":{"leveloff":[100,300]}

}
]}
]}
]}

];

No good, still the same result. URL to script: http://javascript.cooldev.com/scripts/coolmenu/

They have: 51 posts

Joined: Dec 2002

It's got a readme of sorts but it didn't help me much

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I notice

sub:[
{},

at the start of menu item definitions for the other menus. Have you tried adding {} before the Testing node?

It appears the {} should contain styles of some kind for that submenu. The script might detect {code:"Testing"...} as a style definition rather than content.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Yes, that must be it.

Quote: Menu item "SuperItem" contains submenu with two items. SuperItem's member "sub" is an array of subitems. First element (index 0) of this array is common format specifier for submenu. It cannot be ommited but can be empty - {}.

from http://javascript.cooldev.com/scripts/coolmenu/demos/levels/index.html

Wink

They have: 51 posts

Joined: Dec 2002

hey it worked! thanks mate

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Glad to help. Smiling

It's a nice script, though - I might use it on my own site. Thanks for posting about it. Sticking out tongue

Too bad their documentation isn't so good. :\

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.